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

SpeedPointAbstract::valid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
namespace FilmTools\SpeedPoint;
3
4
abstract class SpeedPointAbstract implements SpeedPointInterface
5
{
6
7
    /**
8
     * @var float
9
     */
10
    public $value;
11
12
    /**
13
     * @var string
14
     */
15
    public $type;
16
17
18
19
    /**
20
     * @inheritDoc
21
     */
22 9
    public function valid() : bool
23
    {
24 9
        return !is_null($value = $this->getValue());
25
    }
26
27
28
    /**
29
     * @inheritDoc
30
     */
31 6
    public function getType() : ?string
32
    {
33 6
        return $this->type;
34
    }
35
36
37
    /**
38
     * inheritDoc
39
     */
40 15
    public function getValue() : ?float
41
    {
42 15
        return $this->value;
43
    }
44
45
46
47
    /**
48
     * Subtracts log10( 2 ) from the Speed point value.
49
     *
50
     * inheritDoc
51
     */
52 15
    public function getSpeedLoss() : ?float
53
    {
54 15
        if (!is_null($value = $this->getValue()))
55 12
            return $value - log10(2);
56 3
        return null;
57
    }
58
59
60
61
    /**
62
     * Calculates the number of DIN steps for exposure compensation.
63
     *
64
     * inheritDoc
65
     */
66 15
    public function getEICorrection() : ?float
67
    {
68 15
        if (!is_null($speedloss = $this->getSpeedLoss()))
69 12
            return $speedloss * 10 * -1;
70 3
        return null;
71
    }
72
73
}
74