1 | <?php namespace Arcanedev\GeoLocation\Google\DistanceMatrix; |
||
8 | class DistanceMatrixResponse implements Arrayable, Jsonable, JsonSerializable |
||
9 | { |
||
10 | /* ----------------------------------------------------------------- |
||
11 | | Properties |
||
12 | | ----------------------------------------------------------------- |
||
13 | */ |
||
14 | |||
15 | /** |
||
16 | * The response's data. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $data = []; |
||
21 | |||
22 | /* ----------------------------------------------------------------- |
||
23 | | Constructor |
||
24 | | ----------------------------------------------------------------- |
||
25 | */ |
||
26 | |||
27 | /** |
||
28 | * DistanceMatrixResponse constructor. |
||
29 | * |
||
30 | * @param array $data |
||
31 | */ |
||
32 | public function __construct(array $data = []) |
||
36 | |||
37 | /* ----------------------------------------------------------------- |
||
38 | | Getters & Setters |
||
39 | | ----------------------------------------------------------------- |
||
40 | */ |
||
41 | |||
42 | /** |
||
43 | * Get the raw response. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function getRaw() |
||
51 | |||
52 | /** |
||
53 | * Get a data with a given key. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * @param mixed|null $default |
||
57 | * |
||
58 | * @return mixed |
||
59 | */ |
||
60 | public function get($key, $default = null) |
||
64 | |||
65 | /** |
||
66 | * Get the first origin address. |
||
67 | * |
||
68 | * @return string|null |
||
69 | */ |
||
70 | public function getOriginAddress() |
||
74 | |||
75 | /** |
||
76 | * Get the original addresses. |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | public function getOriginAddresses() |
||
84 | |||
85 | /** |
||
86 | * Get the first destination address. |
||
87 | * |
||
88 | * @return string|null |
||
89 | */ |
||
90 | public function getDestinationAddress() |
||
94 | |||
95 | /** |
||
96 | * Get the destination addresses. |
||
97 | * |
||
98 | * @return array |
||
99 | */ |
||
100 | public function getDestinationAddresses() |
||
104 | |||
105 | /** |
||
106 | * Get the distance (text or value). |
||
107 | * |
||
108 | * @param bool $text |
||
109 | * |
||
110 | * @return string|int |
||
111 | */ |
||
112 | public function getDistance($text = true) |
||
116 | |||
117 | /** |
||
118 | * Get the duration (text or value). |
||
119 | * |
||
120 | * @param bool $text |
||
121 | * |
||
122 | * @return string|int |
||
123 | */ |
||
124 | public function getDuration($text = true) |
||
128 | |||
129 | /* ----------------------------------------------------------------- |
||
130 | | Other Methods |
||
131 | | ----------------------------------------------------------------- |
||
132 | */ |
||
133 | |||
134 | /** |
||
135 | * Convert the object to its JSON representation. |
||
136 | * |
||
137 | * @param int $options |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function toJson($options = 0) |
||
145 | |||
146 | /** |
||
147 | * Convert the object into something JSON serializable. |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | public function jsonSerialize() |
||
155 | |||
156 | /** |
||
157 | * Convert the object to array. |
||
158 | * |
||
159 | * @return array |
||
160 | */ |
||
161 | public function toArray() |
||
176 | |||
177 | /** |
||
178 | * Check if the response's status is OK. |
||
179 | * |
||
180 | * @return bool |
||
181 | */ |
||
182 | public function isOk() |
||
186 | } |
||
187 |