Total Complexity | 14 |
Total Lines | 141 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class Gear extends Serializable implements \JsonSerializable, GearInterface |
||
14 | { |
||
15 | use JsonSerializer; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected string $id; |
||
19 | |||
20 | /** @var float */ |
||
21 | protected float $teeth; |
||
22 | |||
23 | /** @var float */ |
||
24 | protected float $torque; |
||
25 | |||
26 | /** @var float */ |
||
27 | protected float $speed; |
||
28 | |||
29 | /** @var bool */ |
||
30 | protected bool $forward; |
||
31 | |||
32 | /** @var bool */ |
||
33 | protected bool $composed; |
||
34 | |||
35 | /** |
||
36 | * ctor |
||
37 | */ |
||
38 | 8 | public function __construct() |
|
39 | { |
||
40 | 8 | $this->init(); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * init default values |
||
45 | */ |
||
46 | 1 | protected function init(): void |
|
47 | { |
||
48 | 1 | $this->id = ''; |
|
49 | 1 | $this->torque = $this->speed = $this->teeth = 0; |
|
50 | 1 | $this->forward = true; |
|
51 | 1 | $this->composed = false; |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * returns gear id |
||
56 | */ |
||
57 | 4 | public function getId(): string |
|
58 | { |
||
59 | 4 | return $this->id; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * set gear id |
||
64 | */ |
||
65 | 2 | public function setId(string $id): Gear |
|
66 | { |
||
67 | 2 | $this->id = $id; |
|
68 | 2 | return $this; |
|
69 | } |
||
70 | |||
71 | /** |
||
72 | * returns number of tooth |
||
73 | */ |
||
74 | 5 | public function getTeeth(): float |
|
75 | { |
||
76 | 5 | return $this->teeth; |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * set number of tooth |
||
81 | */ |
||
82 | 3 | public function setTeeth(float $teeth): Gear |
|
83 | { |
||
84 | 3 | $this->teeth = $teeth; |
|
85 | 3 | return $this; |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * returns torque in N.m |
||
90 | */ |
||
91 | 4 | public function getTorque(): float |
|
94 | } |
||
95 | |||
96 | /** |
||
97 | * set torque in N.m |
||
98 | */ |
||
99 | 3 | public function setTorque(float $torque): Gear |
|
100 | { |
||
101 | 3 | $this->torque = $torque; |
|
102 | 3 | return $this; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * returns speed in Rpm |
||
107 | */ |
||
108 | 4 | public function getSpeed(): float |
|
109 | { |
||
110 | 4 | return $this->speed; |
|
111 | } |
||
112 | |||
113 | /** |
||
114 | * set speed in Rpm |
||
115 | */ |
||
116 | 3 | public function setSpeed(float $speed): Gear |
|
117 | { |
||
118 | 3 | $this->speed = $speed; |
|
119 | 3 | return $this; |
|
120 | } |
||
121 | |||
122 | /** |
||
123 | * returns true if forward direction |
||
124 | */ |
||
125 | 1 | public function getForward(): bool |
|
126 | { |
||
127 | 1 | return $this->forward; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * set forward direction |
||
132 | */ |
||
133 | 2 | public function setForward(bool $forward): Gear |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * returns true if composed |
||
141 | */ |
||
142 | 1 | public function getComposed(): bool |
|
143 | { |
||
144 | 1 | return $this->composed; |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * set true if composed |
||
149 | */ |
||
150 | 1 | public function setComposed(bool $composed): Gear |
|
154 | } |
||
155 | } |
||
156 |