Term   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 53.33%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 62
ccs 8
cts 15
cp 0.5333
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setVariable() 0 3 1
A __construct() 0 4 1
A getValue() 0 3 1
A getVariable() 0 3 1
A setCoefficient() 0 3 1
A getCoefficient() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Ctefan\Kiwi;
5
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
50
    {
51
        $this->variable = $variable;
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
66
    {
67
        $this->coefficient = $coefficient;
68
    }
69
}