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

Geographic   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
wmc 4

2 Methods

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