| Total Complexity | 4 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class Position implements PositionInterface |
||
| 9 | { |
||
| 10 | /** @var Angle */ |
||
| 11 | private $latitude; |
||
| 12 | |||
| 13 | /** @var Angle */ |
||
| 14 | private $longitude; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor. |
||
| 18 | * |
||
| 19 | * @param Angle $latitude |
||
| 20 | * @param Angle $longitude |
||
| 21 | */ |
||
| 22 | 1 | public function __construct( |
|
| 23 | Angle $latitude, |
||
| 24 | Angle $longitude |
||
| 25 | ) { |
||
| 26 | 1 | $this->latitude = $latitude; |
|
| 27 | 1 | $this->longitude = $longitude; |
|
| 28 | 1 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * Create a position using the numerical representations of latitude and |
||
| 32 | * longitude. |
||
| 33 | * |
||
| 34 | * @param float $latitude |
||
| 35 | * @param float $longitude |
||
| 36 | * |
||
| 37 | * @return Position |
||
| 38 | */ |
||
| 39 | 1 | public static function create(float $latitude, float $longitude): Position |
|
| 40 | { |
||
| 41 | 1 | return new static( |
|
| 42 | 1 | new Angle($latitude, UnitAngle::degrees()), |
|
| 43 | 1 | new Angle($longitude, UnitAngle::degrees()) |
|
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get the latitude coordinate of the current location. |
||
| 49 | * |
||
| 50 | * @return Angle |
||
| 51 | */ |
||
| 52 | 1 | public function getLatitude(): Angle |
|
| 53 | { |
||
| 54 | 1 | return $this->latitude; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Get the longitude coordinate of the current location. |
||
| 59 | * |
||
| 60 | * @return Angle |
||
| 61 | */ |
||
| 62 | 1 | public function getLongitude(): Angle |
|
| 65 | } |
||
| 66 | } |
||
| 67 |