Tests passing

This commit is contained in:
Alex Wulf
2022-07-05 16:03:06 +02:00
parent 7d4547df6a
commit d7ea3fc2a9
2 changed files with 43 additions and 35 deletions

View File

@ -53,12 +53,19 @@ abstract class SkillCalculator
self::validateTeamCountAndPlayersCountPerTeamWithRanges($teamsOfPlayerToRatings, $this->_totalTeamsAllowed, $this->_playersPerTeamAllowed);
}
/**
* @param array<\DNW\Skills\Team> $teams
* @param \DNW\Skills\TeamsRange $totalTeams
* @param \DNW\Skills\PlayersRange $playersPerTeam
* @return void
* @throws \Exception
*/
private static function validateTeamCountAndPlayersCountPerTeamWithRanges(array $teams, TeamsRange $totalTeams, PlayersRange $playersPerTeam)
{
$countOfTeams = 0;
foreach ($teams as $currentTeam) {
if (! $playersPerTeam->isInRange(count($currentTeam))) {
if (! $playersPerTeam->isInRange($currentTeam->count())) {
throw new Exception('Player count is not in range');
}
$countOfTeams++;