Skip to content

Commit 7ae5093

Browse files
Fixed winner mark
1 parent 8e54a0e commit 7ae5093

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Transformers/Winner.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ class Winner extends Base
1111
public function transform(array $data, ?int $roundPrecision): array
1212
{
1313
foreach ($this->order as $key) {
14-
$values = $data[$key];
14+
if ($winner = $this->detectWinner($data[$key])) {
15+
return $winner;
16+
}
17+
}
18+
19+
return $this->detectWinner($data['avg']);
20+
}
1521

16-
$names = $this->find($values);
22+
protected function detectWinner(array $values): ?array
23+
{
24+
$names = $this->find($values);
1725

18-
if (count($names) !== count($values) - 1) {
19-
return $this->winner($values, $names);
20-
}
26+
if (count($names) !== count($values) - 1) {
27+
return $this->winner($values, $names);
2128
}
2229

23-
return [];
30+
return null;
2431
}
2532

2633
protected function winner(array $data, array $names): array

0 commit comments

Comments
 (0)