Longitude::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
namespace ValueObjects\Geography;
4
5
use League\Geotools\Coordinate\Coordinate as BaseCoordinate;
6
use ValueObjects\Exception\InvalidNativeArgumentException;
7
use ValueObjects\Number\Real;
8
9
class Longitude extends Real
10
{
11
    /**
12
     * Returns a new Longitude object
13
     *
14
     * @param $value
15
     * @throws InvalidNativeArgumentException
16
     */
17 12
    public function __construct($value)
18
    {
19 12
        $filteredValue = \filter_var($value, FILTER_VALIDATE_FLOAT);
20
21 12
        if (false === $filteredValue) {
22 1
            throw new InvalidNativeArgumentException($value, array('float'));
23
        }
24
25
        // normalization process through Coordinate object
26 11
        $coordinate = new BaseCoordinate(array(0, $filteredValue));
27 11
        $longitude  = $coordinate->getLongitude();
28
29 11
        $this->value = $longitude;
30 11
    }
31
}
32