Total Complexity | 6 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 53.33% |
Changes | 0 |
1 | <?php |
||
6 | class Term |
||
7 | { |
||
8 | /** |
||
9 | * @var Variable |
||
10 | */ |
||
11 | protected $variable; |
||
12 | |||
13 | /** |
||
14 | * @var float |
||
15 | */ |
||
16 | protected $coefficient; |
||
17 | |||
18 | /** |
||
19 | * Term constructor. |
||
20 | * |
||
21 | * @param Variable $variable |
||
22 | * @param float $coefficient |
||
23 | */ |
||
24 | 21 | public function __construct(Variable $variable, float $coefficient = 1.0) |
|
25 | { |
||
26 | 21 | $this->variable = $variable; |
|
27 | 21 | $this->coefficient = $coefficient; |
|
28 | 21 | } |
|
29 | |||
30 | /** |
||
31 | * @return float |
||
32 | */ |
||
33 | public function getValue(): float |
||
34 | { |
||
35 | return $this->coefficient * $this->variable->getValue(); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return Variable |
||
40 | */ |
||
41 | 21 | public function getVariable(): Variable |
|
42 | { |
||
43 | 21 | return $this->variable; |
|
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param Variable $variable |
||
48 | */ |
||
49 | public function setVariable(Variable $variable): void |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return float |
||
56 | */ |
||
57 | 21 | public function getCoefficient(): float |
|
58 | { |
||
59 | 21 | return $this->coefficient; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * @param float $coefficient |
||
64 | */ |
||
65 | public function setCoefficient(float $coefficient): void |
||
68 | } |
||
69 | } |