Passed
Push — 4.x ( f9780c...a64886 )
by Doug
05:20
created

Geographic::fromSRID()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
/**
3
 * PHPCoord.
4
 *
5
 * @author Doug Wright
6
 */
7
declare(strict_types=1);
8
9
namespace PHPCoord\CoordinateReferenceSystem;
10
11
use function array_merge;
12
use PHPCoord\Exception\UnknownCoordinateReferenceSystemException;
13
14
abstract class Geographic extends CoordinateReferenceSystem
15
{
16 5
    public static function fromSRID(string $srid): self
17
    {
18 5
        if (isset(Geographic2D::getSupportedSRIDs()[$srid])) {
19 3
            return Geographic2D::fromSRID($srid);
20
        }
21
22 2
        if (isset(Geographic3D::getSupportedSRIDs()[$srid])) {
23 1
            return Geographic3D::fromSRID($srid);
24
        }
25
26 1
        throw new UnknownCoordinateReferenceSystemException($srid);
27
    }
28
29 1
    public static function getSupportedSRIDs(): array
30
    {
31 1
        return array_merge(Geographic2D::getSupportedSRIDs(), Geographic3D::getSupportedSRIDs());
32
    }
33
}
34