Passed
Push — master ( 936f3f...6785f1 )
by Doug
09:29
created

Metre   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 31
ccs 13
cts 13
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getUnitName() 0 3 1
A asMetres() 0 3 1
A getValue() 0 3 1
A __construct() 0 3 1
A convert() 0 7 2
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\UnitOfMeasure\Length;
10
11
class Metre extends Length
12
{
13
    private float $length;
14
15 2762
    public function __construct(float $length)
16
    {
17 2762
        $this->length = $length;
18 2762
    }
19
20 1699
    public function asMetres(): self
21
    {
22 1699
        return $this;
23
    }
24
25 2617
    public function getValue(): float
26
    {
27 2617
        return $this->length;
28
    }
29
30 27
    public function getUnitName(): string
31
    {
32 27
        return 'metre';
33
    }
34
35 1742
    public static function convert(Length $length, string $targetSRID): Length
36
    {
37 1742
        if ($targetSRID === self::EPSG_METRE) {
38 1634
            return $length;
39
        }
40
41 117
        return parent::convert($length, $targetSRID);
42
    }
43
}
44