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

Geographic   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromSRID() 0 11 3
A getSupportedSRIDs() 0 3 1
A getSupportedSRIDsWithHelp() 0 3 1
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