1 | <?php |
||
19 | class Robot |
||
20 | { |
||
21 | /** |
||
22 | * Purchased by Rupert, then tanked :). |
||
23 | * |
||
24 | * @var SpaceInterface |
||
25 | */ |
||
26 | private $mySpace; |
||
27 | |||
28 | private $position; |
||
29 | |||
30 | private $facingDirection; |
||
31 | |||
32 | 10 | private function __construct( |
|
41 | |||
42 | /** |
||
43 | * @param SpaceInterface $space |
||
44 | * @param Vector $position |
||
45 | * @param string|null $facingDirection |
||
46 | * |
||
47 | * @return Robot |
||
48 | * |
||
49 | * @throws Assert\AssertionFailedException |
||
50 | */ |
||
51 | 11 | public static function create( |
|
65 | |||
66 | /** |
||
67 | * @return Robot |
||
68 | */ |
||
69 | public function move(): Robot |
||
80 | |||
81 | /** |
||
82 | * @return Robot |
||
83 | */ |
||
84 | public function left(): Robot |
||
90 | |||
91 | /** |
||
92 | * @return Robot |
||
93 | */ |
||
94 | public function right(): Robot |
||
100 | |||
101 | /** |
||
102 | * @return Robot |
||
103 | */ |
||
104 | 2 | public function moveNorthward(): Robot |
|
115 | |||
116 | /** |
||
117 | * @return Robot |
||
118 | */ |
||
119 | 1 | public function moveEastward(): Robot |
|
130 | |||
131 | /** |
||
132 | * @return Robot |
||
133 | */ |
||
134 | 2 | public function moveSouthward(): Robot |
|
145 | |||
146 | /** |
||
147 | * @return Robot |
||
148 | */ |
||
149 | 2 | public function moveWestward(): Robot |
|
160 | |||
161 | /** |
||
162 | * @return Vector |
||
163 | */ |
||
164 | 1 | public function getPosition(): Vector |
|
168 | |||
169 | /** |
||
170 | * @return string In the form 'X,Y,F' |
||
171 | */ |
||
172 | 5 | public function getReportAsString(): string |
|
178 | |||
179 | /** |
||
180 | * @return string |
||
181 | */ |
||
182 | 5 | private function getFacingDirectionAsString(): string |
|
186 | |||
187 | /** |
||
188 | * validateCanMove. |
||
189 | * |
||
190 | * The robot requires a space during construction, however, |
||
191 | * this is extra precautionary in case the space is removed |
||
192 | * |
||
193 | * @throws NotPlacedInSpaceException |
||
194 | */ |
||
195 | 4 | private function validateCanMove(): void |
|
203 | } |
||
204 |