1 | <?php namespace Arcanedev\GeoLocation\Entities\Coordinates; |
||
15 | class Position implements PositionContract |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Traits |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | use CanBeJsonable; |
||
23 | |||
24 | /* ----------------------------------------------------------------- |
||
25 | | Properties |
||
26 | | ----------------------------------------------------------------- |
||
27 | */ |
||
28 | |||
29 | /** |
||
30 | * The latitude coordinate. |
||
31 | * |
||
32 | * @var \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
33 | */ |
||
34 | protected $latitude; |
||
35 | |||
36 | /** |
||
37 | * The longitude coordinate. |
||
38 | * |
||
39 | * @var \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
40 | */ |
||
41 | protected $longitude; |
||
42 | |||
43 | /* ----------------------------------------------------------------- |
||
44 | | Constructor |
||
45 | | ----------------------------------------------------------------- |
||
46 | */ |
||
47 | |||
48 | /** |
||
49 | * Position constructor. |
||
50 | * |
||
51 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate $latitude |
||
52 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate $longitude |
||
53 | */ |
||
54 | 87 | public function __construct(Coordinate $latitude, Coordinate $longitude) |
|
59 | |||
60 | /* ----------------------------------------------------------------- |
||
61 | | Getters & Setters |
||
62 | | ----------------------------------------------------------------- |
||
63 | */ |
||
64 | |||
65 | /** |
||
66 | * Get the latitude coordinate. |
||
67 | * |
||
68 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
69 | */ |
||
70 | 66 | public function getLatitude() |
|
74 | |||
75 | /** |
||
76 | * Get the latitude coordinate (alias). |
||
77 | * |
||
78 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
79 | */ |
||
80 | 42 | public function lat() |
|
84 | |||
85 | /** |
||
86 | * Set the latitude coordinate. |
||
87 | * |
||
88 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate $latitude |
||
89 | * |
||
90 | * @return self |
||
91 | */ |
||
92 | 87 | public function setLatitude(Coordinate $latitude) |
|
98 | |||
99 | /** |
||
100 | * Get the longitude coordinate. |
||
101 | * |
||
102 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
103 | */ |
||
104 | 66 | public function getLongitude() |
|
108 | |||
109 | /** |
||
110 | * Get the longitude coordinate (alias). |
||
111 | * |
||
112 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate |
||
113 | */ |
||
114 | 42 | public function lng() |
|
118 | |||
119 | /** |
||
120 | * Set the longitude coordinate. |
||
121 | * |
||
122 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Coordinate $longitude |
||
123 | * |
||
124 | * @return self |
||
125 | */ |
||
126 | 87 | public function setLongitude(Coordinate $longitude) |
|
132 | |||
133 | /* ----------------------------------------------------------------- |
||
134 | | Main Methods |
||
135 | | ----------------------------------------------------------------- |
||
136 | */ |
||
137 | |||
138 | /** |
||
139 | * Create the position. |
||
140 | * |
||
141 | * @param float $latitude |
||
142 | * @param float $longitude |
||
143 | * |
||
144 | * @return self |
||
145 | */ |
||
146 | 60 | public static function create($latitude, $longitude) |
|
153 | |||
154 | /** |
||
155 | * Create position instance from array. |
||
156 | * |
||
157 | * @param array $location |
||
158 | * |
||
159 | * @return self |
||
160 | */ |
||
161 | 36 | public static function createFromArray(array $location) |
|
165 | |||
166 | /** |
||
167 | * Get the instance as an array. |
||
168 | * |
||
169 | * @return array |
||
170 | */ |
||
171 | 27 | public function toArray() |
|
178 | } |
||
179 |