Total Complexity | 7 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class Car |
||
12 | { |
||
13 | /** @var CarState */ |
||
14 | private CarState $state; |
||
15 | |||
16 | /** |
||
17 | * Car constructor. |
||
18 | * |
||
19 | * @param CarState $state |
||
20 | */ |
||
21 | public function __construct(CarState $state) |
||
22 | { |
||
23 | $this->changeState($state); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param CarState $state |
||
28 | */ |
||
29 | private function changeState(CarState $state): void |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @return $this |
||
36 | */ |
||
37 | public function brake(): Car |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function speedUp(): Car |
||
48 | { |
||
49 | $this->changeState($this->state->speedUp()); |
||
50 | |||
51 | return $this; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return $this |
||
56 | */ |
||
57 | public function turnOff(): Car |
||
58 | { |
||
59 | $this->changeState($this->state->turnOff()); |
||
60 | |||
61 | return $this; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return $this |
||
66 | */ |
||
67 | public function turnOn(): Car |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function isOn(): bool |
||
80 | } |
||
81 | } |
||
82 |