| Conditions | 7 |
| Paths | 30 |
| Total Lines | 23 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 42 | public function __toString(): string |
||
| 43 | { |
||
| 44 | $maze = []; |
||
| 45 | $maxX = 0; |
||
| 46 | $maxY = 0; |
||
| 47 | foreach ($this->walls as $wall) { |
||
| 48 | if ($wall->x() > $maxX) { |
||
| 49 | $maxX = $wall->x(); |
||
| 50 | } |
||
| 51 | if ($wall->y() > $maxY) { |
||
| 52 | $maxY = $wall->y(); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | for ($x = 0; $x < $maxX; ++$x) { |
||
| 56 | for ($y = 0; $y < $maxY; ++$y) { |
||
| 57 | $maze[$y][$x] = ' '; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | foreach ($this->walls as $wall) { |
||
| 61 | $maze[$wall->y()][$wall->x()] = '#'; |
||
| 62 | } |
||
| 63 | $maze[$this->exit->y()][$this->exit->x()] = 'X'; |
||
| 64 | return implode(PHP_EOL, array_map('implode', $maze)); |
||
| 65 | } |
||
| 67 |