Passed
Push — master ( 8bd5c3...1e8670 )
by Doug
62:22
created

Geographic::getSupportedSRIDsWithHelp()   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
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
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