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

Metre::convert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
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