Completed
Push — master ( 9cccc5...d4b7f8 )
by Carsten
05:52 queued 10s
created

SpeedPointDecoratorAbstract::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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_provider instanceOf SpeedPointInterface):
0 ignored issues
show
Bug introduced by
The variable $speedpoint_provider does not exist. Did you mean $speedpoint?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
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