Passed
Push — master ( 8bd5c3...1e8670 )
by Doug
62:22
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 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
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 PHPCoord\Exception\UnknownCoordinateReferenceSystemException;
12
13
use function array_merge;
14
15
abstract class Geographic extends CoordinateReferenceSystem
16
{
17 5743
    public static function fromSRID(string $srid): Geographic2D|Geographic3D
18
    {
19 5743
        if (isset(Geographic2D::getSupportedSRIDs()[$srid])) {
20 4924
            return Geographic2D::fromSRID($srid);
21
        }
22
23 819
        if (isset(Geographic3D::getSupportedSRIDs()[$srid])) {
24 810
            return Geographic3D::fromSRID($srid);
25
        }
26
27 9
        throw new UnknownCoordinateReferenceSystemException($srid);
28
    }
29
30 9
    /**
31
     * @return array<string, string>
32 9
     */
33
    public static function getSupportedSRIDs(): array
34
    {
35
        return array_merge(Geographic2D::getSupportedSRIDs(), Geographic3D::getSupportedSRIDs());
36
    }
37
38
    /**
39
     * @return array<string, array{name: string, extent_description: string, help: string}>
40
     */
41
    public static function getSupportedSRIDsWithHelp(): array
42
    {
43
        return array_merge(Geographic2D::getSupportedSRIDsWithHelp(), Geographic3D::getSupportedSRIDsWithHelp());
44
    }
45
}
46