diff --git a/src/Transformers/Winner.php b/src/Transformers/Winner.php index 3c40a5d..8e182bc 100644 --- a/src/Transformers/Winner.php +++ b/src/Transformers/Winner.php @@ -6,11 +6,21 @@ class Winner extends Base { + protected array $order = ['avg', 'max', 'min']; + public function transform(array $data, ?int $roundPrecision): array { - $values = $data['avg']; + foreach ($this->order as $key) { + $values = $data[$key]; + + $names = $this->find($values); + + if (count($names) !== count($values) - 1) { + return $this->winner($values, $names); + } + } - return $this->winner($values, $this->find($values)); + return []; } protected function winner(array $data, array $names): array