NumberIntervalPoint::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.032
1
<?php
2
3
/**
4
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2016, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Interval\Number;
12
13
use GpsLab\Component\Interval\Exception\InvalidPointTypeException;
14
use GpsLab\Component\Interval\BaseIntervalPoint;
15
16
class NumberIntervalPoint extends BaseIntervalPoint
17
{
18
    /**
19
     * @var float|int
20
     */
21
    private $number;
22
23
    /**
24
     * @param int|float $number
25
     */
26 31
    public function __construct($number)
27
    {
28 31
        if (!is_numeric($number)) {
29
            throw InvalidPointTypeException::type('int|float', $number);
30
        }
31
32 31
        $this->number = $number;
33 31
    }
34
35
    /**
36
     * @return float|int
37
     */
38 31
    public function value()
39
    {
40 31
        return $this->number;
41
    }
42
43
    /**
44
     * @return string
45
     */
46 1
    public function __toString()
47
    {
48 1
        return (string) $this->value();
49
    }
50
}
51