| Total Complexity | 10 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class PlayerTeamCollectionTransformer implements DataTransformerInterface |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param Team $value |
||
| 14 | * @return Team|null |
||
| 15 | */ |
||
| 16 | public function transform($value) |
||
| 17 | { |
||
| 18 | if ($value === null) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | // In want to have 16 players in the list, no less, no more |
||
| 23 | |||
| 24 | $usedNumbers = []; |
||
| 25 | |||
| 26 | foreach ($value->getPlayers() as $player) { |
||
| 27 | $usedNumbers[$player->getNumber()] = $player; |
||
| 28 | } |
||
| 29 | for ($i=1; $i<=16; $i++) { |
||
| 30 | if (!isset($usedNumbers[$i])) { |
||
| 31 | $value->addPlayer((new Player())->setNumber($i)); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | return $value; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param Team $value |
||
| 39 | * @return Team |
||
| 40 | */ |
||
| 41 | public function reverseTransform($value) |
||
| 53 | } |
||
| 54 | } |
||
| 55 |