Passed
Push — master ( eceada...7f199a )
by Carsten
03:06
created

NDeviation::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\NDeviation;
3
4
class NDeviation implements NDeviationInterface, NDeviationProviderInterface
5
{
6
7
    /**
8
     * @var float|null
9
     */
10
    public $ndeviation;
11
12
    /**
13
     * @var string|null
14
     */
15
    public $type;
16
17
18
    /**
19
     * @param float       $ndeviation  Zone system N deviation value
20
     * @param string|null $type        Optional: Short description
21
     */
22 15
    public function __construct( ?float $ndeviation, string $type = null)
23
    {
24 15
        $this->ndeviation = $ndeviation;
25 15
        $this->type = $type;
26 15
    }
27
28
    public function __debugInfo()
29
    {
30
        return [
31
            'type'  => $this->getType(),
32
            'value' => $this->getValue()
33
        ];
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39 12
    public function getType() : ?string
40
    {
41 12
        return $this->type;
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47 12
    public function getValue() : ?float
48
    {
49 12
        return $this->ndeviation;
50
    }
51
52
    /**
53
     * @return bool
54
     */
55
    public function valid() : bool
56
    {
57
        return !is_null( $this->ndeviation );
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63 3
    public function getNDeviation() : NDeviationInterface
64
    {
65 3
        return $this;
66
    }
67
}
68