Total Complexity | 13 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
9 | final class Maze |
||
10 | { |
||
11 | /** @var Goal */ |
||
12 | private $exit; |
||
13 | /** @var Wall[] */ |
||
14 | private $walls; |
||
15 | |||
16 | public function __construct(Goal $exit, Wall ...$walls) |
||
17 | { |
||
18 | $this->exit = $exit; |
||
19 | $this->walls = $walls; |
||
20 | } |
||
21 | |||
22 | public static function withGoalAndWalls(Goal $exit, Wall ...$walls): self |
||
23 | { |
||
24 | return new self($exit, ...$walls); |
||
25 | } |
||
26 | |||
27 | public function isValidPosition(Hero $hero): bool |
||
35 | } |
||
36 | |||
37 | public function isCompletedBy(Hero $hero): bool |
||
38 | { |
||
39 | return $this->exit->isAt($hero->x(), $hero->y()); |
||
40 | } |
||
41 | |||
42 | public function __toString(): string |
||
65 | } |
||
66 | } |
||
67 |