Passed
Pull Request — main (#8)
by Alex
02:23
created

CoordinatesLongitude::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace StraTDeS\VO\Single;
4
5
class CoordinatesLongitude
6
{
7
    private float $value;
8
9 6
    private function __construct(float $value)
10
    {
11 6
        $this->checkLongitudeIsValid($value);
12 4
        $this->value = $value;
13 4
    }
14
15 6
    public static function fromValue(float $value): CoordinatesLongitude
16
    {
17 6
        return new self($value);
18
    }
19
20 2
    public function value(): float
21
    {
22 2
        return $this->value;
23
    }
24
25 6
    private function checkLongitudeIsValid(float $value): void
26
    {
27 6
        if ($value > 180 || $value < -180) {
28 2
            throw new \InvalidArgumentException("Longitude must be a float number between -180.00 and 180.00.");
29
        }
30 4
    }
31
}
32