SpeedPointDecoratorAbstract   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 0
loc 82
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getSpeedPoint() 0 4 1
A valid() 0 4 1
A getType() 0 4 1
A getValue() 0 4 1
A getSpeedLoss() 0 4 1
A getEICorrection() 0 4 1
1
<?php
2
namespace FilmTools\SpeedPoint;
3
4
abstract class SpeedPointDecoratorAbstract implements SpeedPointProviderInterface, SpeedPointInterface
5
{
6
7
    /**
8
     * @var SpeedPointInterface
9
     */
10
    public $speedpoint;
11
12
13
    /**
14
     * @param SpeedPointProviderInterface|SpeedPointInterface $speedpoint
15
     */
16
    public function __construct( $speedpoint)
17
    {
18
        if ($speedpoint instanceOf SpeedPointProviderInterface):
19
            $this->speedpoint = $speedpoint->getSpeedPoint();
20
        elseif ($speedpoint instanceOf SpeedPointInterface):
21
            $this->speedpoint = $speedpoint;
22
        else:
23
            throw new \InvalidArgumentException("SpeedPointInterface or SpeedPointProviderInterface expected");
24
        endif;
25
    }
26
27
28
    /**
29
     * Returns the Decorator instance.
30
     *
31
     * @inheritDoc
32
     * @return SpeedPointDecoratorAbstract
33
     */
34
    public function getSpeedPoint() : SpeedPointInterface
35
    {
36
        return $this;
37
    }
38
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function valid() : bool
44
    {
45
        return $this->speedpoint->valid();
46
    }
47
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function getType() : ?string
53
    {
54
        return $this->speedpoint->getType();
55
    }
56
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function getValue() : ?float
62
    {
63
        return $this->speedpoint->getValue();
64
    }
65
66
67
    /**
68
     * @inheritDoc
69
     */
70
    public function getSpeedLoss() : ?float
71
    {
72
        return $this->speedpoint->getSpeedLoss();
73
    }
74
75
76
    /**
77
     * @inheritDoc
78
     */
79
    public function getEICorrection() : ?float
80
    {
81
        return $this->speedpoint->getEICorrection();
82
    }
83
84
85
}
86