Passed
Push — master ( 705a37...2b8bad )
by Doug
17:25 queued 45s
created

CoordinateSystem   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 52
ccs 9
cts 11
cp 0.8182
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSRID() 0 3 1
A getAxisByName() 0 3 1
A __construct() 0 9 2
A getAxes() 0 3 1
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\CoordinateSystem;
10
11
abstract class CoordinateSystem
12
{
13
    public const CS_TYPE_CARTESIAN = 'Cartesian';
14
15
    public const CS_TYPE_ELLIPSOIDAL = 'ellipsoidal';
16
17
    public const CS_TYPE_ORDINAL = 'ordinal';
18
19
    public const CS_TYPE_SPHERICAL = 'spherical';
20
21
    public const CS_TYPE_VERTICAL = 'vertical';
22
23
    protected string $srid;
24
25
    /**
26
     * @var Axis[]
27
     */
28
    protected array $axes;
29
30
    /**
31
     * @var Axis[]
32
     */
33
    protected array $axesByName;
34
35 189
    public function __construct(
36
        string $srid,
37
        array $axes
38
    ) {
39 189
        $this->srid = $srid;
40 189
        $this->axes = $axes;
41
42 189
        foreach ($this->axes as $axis) {
43 189
            $this->axesByName[$axis->getName()] = $axis;
44
        }
45
    }
46
47
    public function getSRID(): string
48
    {
49
        return $this->srid;
50
    }
51
52
    /**
53
     * @return Axis[]
54
     */
55 1058
    public function getAxes(): array
56
    {
57 1058
        return $this->axes;
58
    }
59
60 2143
    public function getAxisByName(string $name): ?Axis
61
    {
62 2143
        return $this->axesByName[$name] ?? null;
63
    }
64
}
65