Passed
Push — 4.x ( c37faa...bd875a )
by Doug
12:53
created

Point::getAxisByName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 3
nc 3
nop 1
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord;
10
11
use PHPCoord\CoordinateReferenceSystem\CoordinateReferenceSystem;
12
use PHPCoord\CoordinateSystem\Axis;
13
14
abstract class Point implements \Stringable
15
{
16
    abstract public function getCRS(): CoordinateReferenceSystem;
17
18
    protected function getAxisByName(string $name): Axis
19
    {
20
        foreach ($this->getCRS()->getCoordinateSystem()->getAxes() as $axis) {
21
            if ($axis->getName() === $name) {
22
                return $axis;
23
            }
24
        }
25
    }
26
}
27