Passed
Push — master ( 9ef2b1...e5f776 )
by Doug
61:06
created

CoordinateSystem::hasAxisByName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
/**
4
 * PHPCoord.
5
 *
6
 * @author Doug Wright
7
 */
8
declare(strict_types=1);
9
10
namespace PHPCoord\CoordinateSystem;
11
12
abstract class CoordinateSystem
13
{
14
    public const CS_TYPE_CARTESIAN = 'Cartesian';
15
16
    public const CS_TYPE_ELLIPSOIDAL = 'ellipsoidal';
17
18
    public const CS_TYPE_ORDINAL = 'ordinal';
19
20
    public const CS_TYPE_SPHERICAL = 'spherical';
21
22
    public const CS_TYPE_VERTICAL = 'vertical';
23
24
    protected string $srid;
25
26
    /**
27
     * @var Axis[]
28
     */
29
    protected array $axes;
30
31
    /**
32
     * @var Axis[]
33
     */
34
    protected array $axesByName;
35 296
36
    /**
37
     * @param Axis[] $axes
38
     */
39 296
    public function __construct(string $srid, array $axes)
40 296
    {
41
        $this->srid = $srid;
42 296
        $this->axes = $axes;
43 296
        foreach ($this->axes as $axis) {
44
            $this->axesByName[$axis->getName()] = $axis;
45
        }
46
    }
47
48
    public function getSRID(): string
49
    {
50
        return $this->srid;
51
    }
52
53
    /**
54
     * @return Axis[]
55 14474
     */
56
    public function getAxes(): array
57 14474
    {
58
        return $this->axes;
59
    }
60 7323
61
    public function getAxisByName(string $name): Axis
62 7323
    {
63
        return $this->axesByName[$name];
64
    }
65
66
    public function hasAxisByName(string $name): bool
67
    {
68
        return isset($this->axesByName[$name]);
69
    }
70
}
71