1 | <?php namespace Arcanedev\GeoLocation\Google; |
||
15 | abstract class AbstractResponse implements Arrayable, Jsonable, JsonSerializable |
||
16 | { |
||
17 | /* ----------------------------------------------------------------- |
||
18 | | Traits |
||
19 | | ----------------------------------------------------------------- |
||
20 | */ |
||
21 | |||
22 | use CanBeJsonable; |
||
23 | |||
24 | /* ----------------------------------------------------------------- |
||
25 | | Properties |
||
26 | | ----------------------------------------------------------------- |
||
27 | */ |
||
28 | |||
29 | /** |
||
30 | * The response's data. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $data = []; |
||
35 | |||
36 | /* ----------------------------------------------------------------- |
||
37 | | Constructor |
||
38 | | ----------------------------------------------------------------- |
||
39 | */ |
||
40 | |||
41 | /** |
||
42 | * AbstractResponse constructor. |
||
43 | * |
||
44 | * @param array $data |
||
45 | */ |
||
46 | 102 | public function __construct(array $data = []) |
|
50 | |||
51 | /* ----------------------------------------------------------------- |
||
52 | | Getters & Setters |
||
53 | | ----------------------------------------------------------------- |
||
54 | */ |
||
55 | |||
56 | /** |
||
57 | * Get the raw response. |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | 96 | public function getRaw() |
|
65 | |||
66 | /* ----------------------------------------------------------------- |
||
67 | | Main Methods |
||
68 | | ----------------------------------------------------------------- |
||
69 | */ |
||
70 | |||
71 | /** |
||
72 | * Get a data with a given key. |
||
73 | * |
||
74 | * @param string $key |
||
75 | * @param mixed|null $default |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | 90 | public function get($key, $default = null) |
|
83 | |||
84 | /** |
||
85 | * Check if the response's status is OK. |
||
86 | * |
||
87 | * @return bool |
||
88 | */ |
||
89 | 33 | public function isOk() |
|
93 | } |
||
94 |