HR::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace SportTrackerConnector\Core\Workout\Extension;
6
7
use Assert\Assertion;
8
9
/**
10
 * Heart rate track point extension.
11
 */
12
final class HR implements ExtensionInterface
13
{
14
    /**
15
     * Value of the heart rate.
16
     *
17
     * @var int
18
     */
19
    private $value;
20
21
    /**
22
     * @param int $value
23
     */
24
    private function __construct(?int $value)
25
    {
26
        Assertion::greaterOrEqualThan($value, 40);
27
        Assertion::lessOrEqualThan($value, 210);
28
29
        $this->value = $value;
30
    }
31
32
    /**
33
     * @param mixed $value
34
     * @return HR
35
     */
36
    public static function fromValue($value): HR
37
    {
38
        Assertion::integerish($value);
39
40
        return new self((int)$value);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function value()
47
    {
48
        return $this->value;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public static function ID(): string
55
    {
56
        return 'HR';
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function name(): string
63
    {
64
        return 'Heart rate';
65
    }
66
}
67