File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments