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 | 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 | 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 | public function get($key, $default = null) |
||
72 | |||
73 | /** |
||
74 | * Get the formatted address. |
||
75 | * |
||
76 | * @return string|null |
||
77 | */ |
||
78 | public function getFormattedAddress() |
||
82 | |||
83 | /** |
||
84 | * Get the separate address components. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | public function getAddressComponents() |
||
92 | |||
93 | /** |
||
94 | * Get the location's position. |
||
95 | * |
||
96 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Position |
||
97 | */ |
||
98 | public function getLocationPosition() |
||
104 | |||
105 | /** |
||
106 | * Get the location's type. |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | public function getLocationType() |
||
114 | |||
115 | /** |
||
116 | * Get the viewport coordinates. |
||
117 | * |
||
118 | * @return \Arcanedev\GeoLocation\Entities\Viewport |
||
119 | */ |
||
120 | public function getViewport() |
||
127 | |||
128 | /* ----------------------------------------------------------------- |
||
129 | | Other Methods |
||
130 | | ----------------------------------------------------------------- |
||
131 | */ |
||
132 | |||
133 | /** |
||
134 | * Convert the object to its JSON representation. |
||
135 | * |
||
136 | * @param int $options |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function toJson($options = 0) |
||
144 | |||
145 | /** |
||
146 | * Convert the object into something JSON serializable. |
||
147 | * |
||
148 | * @return array |
||
149 | */ |
||
150 | public function jsonSerialize() |
||
154 | |||
155 | /** |
||
156 | * Convert the object to array. |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | public function toArray() |
||
166 | |||
167 | /** |
||
168 | * Check if the response's status is OK. |
||
169 | * |
||
170 | * @return bool |
||
171 | */ |
||
172 | public function isOk() |
||
176 | |||
177 | /** |
||
178 | * Create the position instance. |
||
179 | * |
||
180 | * @param array $coordinates |
||
181 | * |
||
182 | * @return \Arcanedev\GeoLocation\Entities\Position |
||
183 | */ |
||
184 | protected function createPosition(array $coordinates) |
||
191 | } |
||
192 |