Skip to content

Commit

Permalink
Fixed winner mark
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-helldar committed Feb 3, 2023
1 parent 8e54a0e commit 7ae5093
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Transformers/Winner.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ class Winner extends Base
public function transform(array $data, ?int $roundPrecision): array
{
foreach ($this->order as $key) {
$values = $data[$key];
if ($winner = $this->detectWinner($data[$key])) {
return $winner;
}
}

return $this->detectWinner($data['avg']);
}

$names = $this->find($values);
protected function detectWinner(array $values): ?array
{
$names = $this->find($values);

if (count($names) !== count($values) - 1) {
return $this->winner($values, $names);
}
if (count($names) !== count($values) - 1) {
return $this->winner($values, $names);
}

return [];
return null;
}

protected function winner(array $data, array $names): array
Expand Down

0 comments on commit 7ae5093

Please sign in to comment.