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

CoordinatesLongitude   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 24
rs 10
ccs 11
cts 11
cp 1
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A checkLongitudeIsValid() 0 4 3
A fromValue() 0 3 1
A __construct() 0 4 1
A value() 0 3 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