Passed
Pull Request — main (#8)
by Alex
03:11 queued 01:35
created

CoordinatesLatitude   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A checkLatitudeIsValid() 0 4 3
A value() 0 3 1
A fromValue() 0 3 1
1
<?php
2
3
namespace StraTDeS\VO\Single;
4
5
class CoordinatesLatitude
6
{
7
    private float $value;
8
9 6
    private function __construct(float $value)
10
    {
11 6
        $this->checkLatitudeIsValid($value);
12 4
        $this->value = $value;
13 4
    }
14
15 6
    public static function fromValue(float $value): CoordinatesLatitude
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 checkLatitudeIsValid(float $value): void
26
    {
27 6
        if ($value > 90 || $value < -90) {
28 2
            throw new \InvalidArgumentException("Latitude must be a float number between -90.00 and 90.00.");
29
        }
30 4
    }
31
}
32