| Total Complexity | 7 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class UnitOfMeasureFactory |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @param float|string $measurement |
||
| 21 | */ |
||
| 22 | 85 | public static function makeUnit($measurement, string $srid): UnitOfMeasure |
|
| 23 | { |
||
| 24 | 85 | if (isset(Angle::getSupportedSRIDs()[$srid])) { |
|
| 25 | 21 | return Angle::makeUnit($measurement, $srid); |
|
| 26 | } |
||
| 27 | |||
| 28 | 64 | if (isset(Length::getSupportedSRIDs()[$srid])) { |
|
| 29 | 47 | return Length::makeUnit($measurement, $srid); |
|
|
|
|||
| 30 | } |
||
| 31 | |||
| 32 | 17 | if (isset(Scale::getSupportedSRIDs()[$srid])) { |
|
| 33 | 4 | return Scale::makeUnit($measurement, $srid); |
|
| 34 | } |
||
| 35 | |||
| 36 | 13 | if (isset(Time::getSupportedSRIDs()[$srid])) { |
|
| 37 | 2 | return Time::makeUnit($measurement, $srid); |
|
| 38 | } |
||
| 39 | |||
| 40 | 11 | if (isset(Rate::getSupportedSRIDs()[$srid])) { |
|
| 41 | 10 | return Rate::makeUnit($measurement, $srid); |
|
| 42 | } |
||
| 43 | |||
| 44 | 1 | throw new UnknownUnitOfMeasureException($srid); |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | public static function getSupportedSRIDs(): array |
|
| 50 | } |
||
| 51 | } |
||
| 52 |