Passed
Push — master ( 99135b...c08bef )
by Doug
16:52
created

CoordinateSystem::getAxisByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 189
    }
46
47
    public function getSRID(): string
48
    {
49
        return $this->srid;
50
    }
51
52
    /**
53
     * @return Axis[]
54
     */
55 1018
    public function getAxes(): array
56
    {
57 1018
        return $this->axes;
58
    }
59
60 2111
    public function getAxisByName(string $name): ?Axis
61
    {
62 2111
        return $this->axesByName[$name] ?? null;
63
    }
64
}
65