| Conditions | 4 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 6 | public function transformToString(Map $map, int $width = 0): string |
|
| 16 | { |
||
| 17 | 6 | $stringMap = ''; |
|
| 18 | |||
| 19 | /** @var Location $location */ |
||
| 20 | 6 | $mapLocations = $map->toArray(); |
|
| 21 | |||
| 22 | 6 | if (!count($mapLocations)) { |
|
| 23 | 1 | return $stringMap; |
|
| 24 | } |
||
| 25 | |||
| 26 | 5 | if ($width > 0) { |
|
| 27 | 3 | foreach (array_chunk($mapLocations, $width) as $locations) { |
|
| 28 | 3 | $stringMap .= $this->createStringSequence($locations); |
|
| 29 | 3 | $stringMap .= PHP_EOL; |
|
| 30 | } |
||
| 31 | } else { |
||
| 32 | 2 | $stringMap = $this->createStringSequence($mapLocations); |
|
| 33 | } |
||
| 34 | |||
| 35 | 5 | return $stringMap; |
|
| 36 | } |
||
| 37 | |||
| 61 |