1 | <?php namespace Arcanedev\GeoLocation\Entities; |
||
12 | class Viewport implements ViewportContract |
||
13 | { |
||
14 | /* ----------------------------------------------------------------- |
||
15 | | Properties |
||
16 | | ----------------------------------------------------------------- |
||
17 | */ |
||
18 | |||
19 | /** @var \Arcanedev\GeoLocation\Contracts\Entities\Position */ |
||
20 | protected $northeast; |
||
21 | |||
22 | /** @var \Arcanedev\GeoLocation\Contracts\Entities\Position */ |
||
23 | protected $southwest; |
||
24 | |||
25 | /* ----------------------------------------------------------------- |
||
26 | | Constructor |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * Viewport constructor. |
||
32 | * |
||
33 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $northeast |
||
34 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $southwest |
||
35 | */ |
||
36 | 21 | public function __construct(PositionContract $northeast, PositionContract $southwest) |
|
40 | |||
41 | /* ----------------------------------------------------------------- |
||
42 | | Getters & Setters |
||
43 | | ----------------------------------------------------------------- |
||
44 | */ |
||
45 | |||
46 | /** |
||
47 | * Get the North/East coordinates. |
||
48 | * |
||
49 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Position |
||
50 | */ |
||
51 | 6 | public function getNorthEast() |
|
55 | |||
56 | /** |
||
57 | * Set the North/East coordinates. |
||
58 | * |
||
59 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $northeast |
||
60 | * |
||
61 | * @return self |
||
62 | */ |
||
63 | 21 | public function setNorthEast(PositionContract $northeast) |
|
69 | |||
70 | /** |
||
71 | * Get the South/West coordinates. |
||
72 | * |
||
73 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Position |
||
74 | */ |
||
75 | 6 | public function getSouthWest() |
|
79 | |||
80 | /** |
||
81 | * Set the South/West coordinates. |
||
82 | * |
||
83 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $southwest |
||
84 | * |
||
85 | * @return self |
||
86 | */ |
||
87 | 21 | public function setSouthWest(PositionContract $southwest) |
|
93 | |||
94 | /* ----------------------------------------------------------------- |
||
95 | | Main Methods |
||
96 | | ----------------------------------------------------------------- |
||
97 | */ |
||
98 | |||
99 | /** |
||
100 | * Create a new viewport instance. |
||
101 | * |
||
102 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $northeast |
||
103 | * @param \Arcanedev\GeoLocation\Contracts\Entities\Position $southwest |
||
104 | * |
||
105 | * @return self |
||
106 | */ |
||
107 | 18 | public static function create(PositionContract $northeast, PositionContract $southwest) |
|
111 | |||
112 | /** |
||
113 | * Convert the object to its JSON representation. |
||
114 | * |
||
115 | * @param int $options |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | 3 | public function toJson($options = 0) |
|
120 | { |
||
121 | 3 | return json_encode($this->jsonSerialize(), $options); |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * Convert the object into something JSON serializable. |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | 3 | public function jsonSerialize() |
|
130 | { |
||
131 | 3 | return $this->toArray(); |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * Get the instance as an array. |
||
136 | * |
||
137 | * @return array |
||
138 | */ |
||
139 | 15 | public function toArray() |
|
146 | } |
||
147 |