1 | <?php namespace Arcanedev\GeoLocation\Google\Geocoding; |
||
16 | class GeocodingResponse implements Arrayable, Jsonable, JsonSerializable |
||
17 | { |
||
18 | /* ----------------------------------------------------------------- |
||
19 | | Properties |
||
20 | | ----------------------------------------------------------------- |
||
21 | */ |
||
22 | |||
23 | /** |
||
24 | * The response's data. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $data = []; |
||
29 | |||
30 | /* ----------------------------------------------------------------- |
||
31 | | Constructor |
||
32 | | ----------------------------------------------------------------- |
||
33 | */ |
||
34 | |||
35 | /** |
||
36 | * DistanceMatrixResponse constructor. |
||
37 | * |
||
38 | * @param array $data |
||
39 | */ |
||
40 | 36 | public function __construct(array $data = []) |
|
44 | |||
45 | /* ----------------------------------------------------------------- |
||
46 | | Getters & Setters |
||
47 | | ----------------------------------------------------------------- |
||
48 | */ |
||
49 | |||
50 | /** |
||
51 | * Get the raw response. |
||
52 | * |
||
53 | * @return array |
||
54 | */ |
||
55 | 33 | public function getRaw() |
|
59 | |||
60 | /** |
||
61 | * Get a data with a given key. |
||
62 | * |
||
63 | * @param string $key |
||
64 | * @param mixed|null $default |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | 30 | public function get($key, $default = null) |
|
72 | |||
73 | /** |
||
74 | * Get the formatted address. |
||
75 | * |
||
76 | * @return string|null |
||
77 | */ |
||
78 | 9 | public function getFormattedAddress() |
|
82 | |||
83 | /** |
||
84 | * Get the separate address components. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | 9 | public function getAddressComponents() |
|
92 | |||
93 | /** |
||
94 | * Get the location's position. |
||
95 | * |
||
96 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Position |
||
97 | */ |
||
98 | 9 | public function getLocationPosition() |
|
104 | |||
105 | /** |
||
106 | * Get the location's type. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | 9 | public function getLocationType() |
|
114 | |||
115 | /** |
||
116 | * Get the viewport coordinates. |
||
117 | * |
||
118 | * @return \Arcanedev\GeoLocation\Entities\Viewport |
||
119 | */ |
||
120 | 9 | public function getViewport() |
|
127 | |||
128 | /** |
||
129 | * Get the place id. |
||
130 | * |
||
131 | * @return string|null |
||
132 | */ |
||
133 | 9 | public function getPlaceId() |
|
137 | |||
138 | /* ----------------------------------------------------------------- |
||
139 | | Other Methods |
||
140 | | ----------------------------------------------------------------- |
||
141 | */ |
||
142 | |||
143 | /** |
||
144 | * Convert the object to its JSON representation. |
||
145 | * |
||
146 | * @param int $options |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | 3 | public function toJson($options = 0) |
|
154 | |||
155 | /** |
||
156 | * Convert the object into something JSON serializable. |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | 3 | public function jsonSerialize() |
|
164 | |||
165 | /** |
||
166 | * Convert the object to array. |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | 6 | public function toArray() |
|
181 | |||
182 | /** |
||
183 | * Check if the response's status is OK. |
||
184 | * |
||
185 | * @return bool |
||
186 | */ |
||
187 | 6 | public function isOk() |
|
191 | |||
192 | /** |
||
193 | * Create the position instance. |
||
194 | * |
||
195 | * @param array $coordinates |
||
196 | * |
||
197 | * @return \Arcanedev\GeoLocation\Entities\Position |
||
198 | */ |
||
199 | 12 | protected function createPosition(array $coordinates) |
|
206 | } |
||
207 |