1 | <?php namespace Arcanedev\GeoLocation\Google\Geocoding; |
||
13 | class GeocodingResponse extends AbstractResponse |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Getters & Setters |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * Get the formatted address. |
||
22 | * |
||
23 | * @return string|null |
||
24 | */ |
||
25 | 12 | public function getFormattedAddress() |
|
29 | |||
30 | /** |
||
31 | * Get the separate address components. |
||
32 | * |
||
33 | * @return array |
||
34 | */ |
||
35 | 9 | public function getAddressComponents() |
|
39 | |||
40 | /** |
||
41 | * Get the location's position. |
||
42 | * |
||
43 | * @return \Arcanedev\GeoLocation\Contracts\Entities\Coordinates\Position |
||
44 | */ |
||
45 | 12 | public function getLocationPosition() |
|
46 | { |
||
47 | 12 | return Position::createFromArray( |
|
48 | 12 | $this->get('results.0.geometry.location', []) |
|
49 | ); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the location's type. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 9 | public function getLocationType() |
|
61 | |||
62 | /** |
||
63 | * Get the viewport coordinates. |
||
64 | * |
||
65 | * @return \Arcanedev\GeoLocation\Entities\Coordinates\Viewport |
||
66 | */ |
||
67 | 9 | public function getViewport() |
|
68 | { |
||
69 | 9 | return Viewport::create( |
|
70 | 9 | Position::createFromArray($this->get('results.0.geometry.viewport.northeast', [])), |
|
71 | 9 | Position::createFromArray($this->get('results.0.geometry.viewport.southwest', [])) |
|
72 | ); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Get the place id. |
||
77 | * |
||
78 | * @return string|null |
||
79 | */ |
||
80 | 9 | public function getPlaceId() |
|
84 | |||
85 | /* ----------------------------------------------------------------- |
||
86 | | Other Methods |
||
87 | | ----------------------------------------------------------------- |
||
88 | */ |
||
89 | |||
90 | /** |
||
91 | * Convert the object to array. |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | 6 | public function toArray() |
|
106 | } |
||
107 |