@@ -106,7 +106,7 @@ |
||
| 106 | 106 | public function createRequest(array $params, ?string $endpoint = null): GoogleMapsRequest |
| 107 | 107 | { |
| 108 | 108 | |
| 109 | - $this->request = new GoogleMapsRequest($params, $endpoint);; |
|
| 109 | + $this->request = new GoogleMapsRequest($params, $endpoint); ; |
|
| 110 | 110 | |
| 111 | 111 | return $this->request; |
| 112 | 112 | } |
@@ -25,182 +25,182 @@ |
||
| 25 | 25 | abstract class Api |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - const SERVICE_ENDPOINT = null; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var GoogleMapsApi |
|
| 35 | - */ |
|
| 36 | - protected $google_maps_api = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string |
|
| 40 | - */ |
|
| 41 | - protected $result_type = ''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - protected $result_collection_type = ''; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var GoogleMapsResponse |
|
| 50 | - */ |
|
| 51 | - protected $response; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var GoogleMapsRequest |
|
| 55 | - */ |
|
| 56 | - protected $request; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Api constructor. |
|
| 60 | - * |
|
| 61 | - * @param array $config |
|
| 62 | - */ |
|
| 63 | - public function __construct(array $config = []) |
|
| 64 | - { |
|
| 65 | - |
|
| 66 | - $service_config = $this->getServiceConfig($config); |
|
| 67 | - $this->setGoogleMapsApi(new GoogleMapsApi($service_config)); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @param array $config |
|
| 72 | - * |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - protected function getServiceConfig(array $config = []): array |
|
| 76 | - { |
|
| 77 | - |
|
| 78 | - return array_merge($config, [ |
|
| 79 | - GoogleMapsApiConfigFields::SERVICE_ENDPOINT => $this->getServiceEndpoint() |
|
| 80 | - ]); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @return string |
|
| 85 | - */ |
|
| 86 | - public function getServiceEndpoint(): string |
|
| 87 | - { |
|
| 88 | - |
|
| 89 | - return static::SERVICE_ENDPOINT ?? ''; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @param array $params |
|
| 94 | - * @param null|string $endpoint |
|
| 95 | - * |
|
| 96 | - * @return GoogleMapsResult|GoogleMapsResultsCollection |
|
| 97 | - */ |
|
| 98 | - public function callApi(array $params, ?string $endpoint = null) |
|
| 99 | - { |
|
| 100 | - |
|
| 101 | - $this->createRequest($params, $endpoint); |
|
| 102 | - |
|
| 103 | - return $this->getResponseResult(); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @param array $params |
|
| 108 | - * @param null|string $endpoint since 0.5.0 |
|
| 109 | - * |
|
| 110 | - * @return GoogleMapsRequest |
|
| 111 | - */ |
|
| 112 | - public function createRequest(array $params, ?string $endpoint = null): GoogleMapsRequest |
|
| 113 | - { |
|
| 114 | - |
|
| 115 | - $this->request = new GoogleMapsRequest($params, $endpoint);; |
|
| 116 | - |
|
| 117 | - return $this->request; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @return GoogleMapsResult|GoogleMapsResultsCollection |
|
| 122 | - */ |
|
| 123 | - public function getResponseResult() |
|
| 124 | - { |
|
| 125 | - |
|
| 126 | - $result = $this->getResponse()->getResult(); |
|
| 127 | - if ($result) { |
|
| 128 | - $result_type = $this->result_type; |
|
| 129 | - |
|
| 130 | - return new $result_type($result); |
|
| 131 | - } |
|
| 132 | - $results = $this->getResponse()->getResults(); |
|
| 133 | - |
|
| 134 | - $result_collection_type_class = $this->result_collection_type; |
|
| 135 | - |
|
| 136 | - return new $result_collection_type_class($results); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return GoogleMapsResponse |
|
| 141 | - */ |
|
| 142 | - public function getResponse(): GoogleMapsResponse |
|
| 143 | - { |
|
| 144 | - |
|
| 145 | - $this->response = $this->getGoogleMapsApi()->get($this->request); |
|
| 146 | - |
|
| 147 | - return $this->response; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @return GoogleMapsApi |
|
| 152 | - */ |
|
| 153 | - public function getGoogleMapsApi(): GoogleMapsApi |
|
| 154 | - { |
|
| 155 | - |
|
| 156 | - return $this->google_maps_api; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * @param GoogleMapsApi $google_maps_api |
|
| 161 | - * |
|
| 162 | - * @return Api |
|
| 163 | - */ |
|
| 164 | - public function setGoogleMapsApi(GoogleMapsApi $google_maps_api): Api |
|
| 165 | - { |
|
| 166 | - |
|
| 167 | - $this->google_maps_api = $google_maps_api; |
|
| 168 | - |
|
| 169 | - return $this; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @return GoogleMapsResultsCollection |
|
| 174 | - */ |
|
| 175 | - public function getSingleResult(): GoogleMapsResultsCollection |
|
| 176 | - { |
|
| 177 | - |
|
| 178 | - $results = $this->getResponse()->getResults(); |
|
| 179 | - |
|
| 180 | - $result_collection_type_class = $this->result_collection_type; |
|
| 181 | - |
|
| 182 | - return new $result_collection_type_class($results); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @return GoogleMapsResultsCollection |
|
| 187 | - */ |
|
| 188 | - public function getNextPage(): GoogleMapsResultsCollection |
|
| 189 | - { |
|
| 190 | - |
|
| 191 | - if ($this->responseHasNewPage()) { |
|
| 192 | - $this->request->setParam(GoogleMapsRequestFields::NEXT_PAGE_TOKEN, $this->response->getNextPageToken()); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $this->getResponseResult(); |
|
| 196 | - } |
|
| 28 | + /** |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + const SERVICE_ENDPOINT = null; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var GoogleMapsApi |
|
| 35 | + */ |
|
| 36 | + protected $google_maps_api = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string |
|
| 40 | + */ |
|
| 41 | + protected $result_type = ''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + protected $result_collection_type = ''; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var GoogleMapsResponse |
|
| 50 | + */ |
|
| 51 | + protected $response; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var GoogleMapsRequest |
|
| 55 | + */ |
|
| 56 | + protected $request; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Api constructor. |
|
| 60 | + * |
|
| 61 | + * @param array $config |
|
| 62 | + */ |
|
| 63 | + public function __construct(array $config = []) |
|
| 64 | + { |
|
| 65 | + |
|
| 66 | + $service_config = $this->getServiceConfig($config); |
|
| 67 | + $this->setGoogleMapsApi(new GoogleMapsApi($service_config)); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @param array $config |
|
| 72 | + * |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + protected function getServiceConfig(array $config = []): array |
|
| 76 | + { |
|
| 77 | + |
|
| 78 | + return array_merge($config, [ |
|
| 79 | + GoogleMapsApiConfigFields::SERVICE_ENDPOINT => $this->getServiceEndpoint() |
|
| 80 | + ]); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @return string |
|
| 85 | + */ |
|
| 86 | + public function getServiceEndpoint(): string |
|
| 87 | + { |
|
| 88 | + |
|
| 89 | + return static::SERVICE_ENDPOINT ?? ''; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @param array $params |
|
| 94 | + * @param null|string $endpoint |
|
| 95 | + * |
|
| 96 | + * @return GoogleMapsResult|GoogleMapsResultsCollection |
|
| 97 | + */ |
|
| 98 | + public function callApi(array $params, ?string $endpoint = null) |
|
| 99 | + { |
|
| 100 | + |
|
| 101 | + $this->createRequest($params, $endpoint); |
|
| 102 | + |
|
| 103 | + return $this->getResponseResult(); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @param array $params |
|
| 108 | + * @param null|string $endpoint since 0.5.0 |
|
| 109 | + * |
|
| 110 | + * @return GoogleMapsRequest |
|
| 111 | + */ |
|
| 112 | + public function createRequest(array $params, ?string $endpoint = null): GoogleMapsRequest |
|
| 113 | + { |
|
| 114 | + |
|
| 115 | + $this->request = new GoogleMapsRequest($params, $endpoint);; |
|
| 116 | + |
|
| 117 | + return $this->request; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @return GoogleMapsResult|GoogleMapsResultsCollection |
|
| 122 | + */ |
|
| 123 | + public function getResponseResult() |
|
| 124 | + { |
|
| 125 | + |
|
| 126 | + $result = $this->getResponse()->getResult(); |
|
| 127 | + if ($result) { |
|
| 128 | + $result_type = $this->result_type; |
|
| 129 | + |
|
| 130 | + return new $result_type($result); |
|
| 131 | + } |
|
| 132 | + $results = $this->getResponse()->getResults(); |
|
| 133 | + |
|
| 134 | + $result_collection_type_class = $this->result_collection_type; |
|
| 135 | + |
|
| 136 | + return new $result_collection_type_class($results); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return GoogleMapsResponse |
|
| 141 | + */ |
|
| 142 | + public function getResponse(): GoogleMapsResponse |
|
| 143 | + { |
|
| 144 | + |
|
| 145 | + $this->response = $this->getGoogleMapsApi()->get($this->request); |
|
| 146 | + |
|
| 147 | + return $this->response; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @return GoogleMapsApi |
|
| 152 | + */ |
|
| 153 | + public function getGoogleMapsApi(): GoogleMapsApi |
|
| 154 | + { |
|
| 155 | + |
|
| 156 | + return $this->google_maps_api; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * @param GoogleMapsApi $google_maps_api |
|
| 161 | + * |
|
| 162 | + * @return Api |
|
| 163 | + */ |
|
| 164 | + public function setGoogleMapsApi(GoogleMapsApi $google_maps_api): Api |
|
| 165 | + { |
|
| 166 | + |
|
| 167 | + $this->google_maps_api = $google_maps_api; |
|
| 168 | + |
|
| 169 | + return $this; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @return GoogleMapsResultsCollection |
|
| 174 | + */ |
|
| 175 | + public function getSingleResult(): GoogleMapsResultsCollection |
|
| 176 | + { |
|
| 177 | + |
|
| 178 | + $results = $this->getResponse()->getResults(); |
|
| 179 | + |
|
| 180 | + $result_collection_type_class = $this->result_collection_type; |
|
| 181 | + |
|
| 182 | + return new $result_collection_type_class($results); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @return GoogleMapsResultsCollection |
|
| 187 | + */ |
|
| 188 | + public function getNextPage(): GoogleMapsResultsCollection |
|
| 189 | + { |
|
| 190 | + |
|
| 191 | + if ($this->responseHasNewPage()) { |
|
| 192 | + $this->request->setParam(GoogleMapsRequestFields::NEXT_PAGE_TOKEN, $this->response->getNextPageToken()); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $this->getResponseResult(); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * @return bool |
|
| 200 | - */ |
|
| 201 | - public function responseHasNewPage(): bool |
|
| 202 | - { |
|
| 198 | + /** |
|
| 199 | + * @return bool |
|
| 200 | + */ |
|
| 201 | + public function responseHasNewPage(): bool |
|
| 202 | + { |
|
| 203 | 203 | |
| 204 | - return ($this->response instanceof GoogleMapsResponse) ? $this->response->getNextPageToken() : false; |
|
| 205 | - } |
|
| 204 | + return ($this->response instanceof GoogleMapsResponse) ? $this->response->getNextPageToken() : false; |
|
| 205 | + } |
|
| 206 | 206 | } |
| 207 | 207 | \ No newline at end of file |
@@ -17,15 +17,15 @@ |
||
| 17 | 17 | class GoogleMapsResponseFormat |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * string: json |
|
| 22 | - */ |
|
| 23 | - const JSON = 'json'; |
|
| 20 | + /** |
|
| 21 | + * string: json |
|
| 22 | + */ |
|
| 23 | + const JSON = 'json'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * string: xml |
|
| 27 | - * NOT supported in this version |
|
| 28 | - */ |
|
| 29 | - const XML = 'xml'; |
|
| 25 | + /** |
|
| 26 | + * string: xml |
|
| 27 | + * NOT supported in this version |
|
| 28 | + */ |
|
| 29 | + const XML = 'xml'; |
|
| 30 | 30 | |
| 31 | 31 | } |
| 32 | 32 | \ No newline at end of file |
@@ -17,18 +17,18 @@ |
||
| 17 | 17 | class GoogleMapsApiConfigFields |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * string: key |
|
| 22 | - */ |
|
| 23 | - const KEY = 'key'; |
|
| 20 | + /** |
|
| 21 | + * string: key |
|
| 22 | + */ |
|
| 23 | + const KEY = 'key'; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * string: sensor |
|
| 27 | - */ |
|
| 28 | - const SENSOR = 'sensor'; |
|
| 25 | + /** |
|
| 26 | + * string: sensor |
|
| 27 | + */ |
|
| 28 | + const SENSOR = 'sensor'; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * string: service_endpoint |
|
| 32 | - */ |
|
| 33 | - const SERVICE_ENDPOINT = 'service_endpoint'; |
|
| 30 | + /** |
|
| 31 | + * string: service_endpoint |
|
| 32 | + */ |
|
| 33 | + const SERVICE_ENDPOINT = 'service_endpoint'; |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | class GeocodingResultsCollection extends GoogleMapsResultsCollection |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $item_class = GeocodingResult::class; |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $item_class = GeocodingResult::class; |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | class ElevationResultsCollection extends GoogleMapsResultsCollection |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $item_class = ElevationResult::class; |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $item_class = ElevationResult::class; |
|
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | class PlaceResultsCollection extends GoogleMapsResultsCollection |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected $item_class = PlacesResult::class; |
|
| 24 | + /** |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected $item_class = PlacesResult::class; |
|
| 28 | 28 | } |
| 29 | 29 | \ No newline at end of file |
@@ -35,49 +35,49 @@ |
||
| 35 | 35 | class GeocodingResult extends GoogleMapsResult |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var Address |
|
| 40 | - */ |
|
| 41 | - protected $address_components = null; |
|
| 38 | + /** |
|
| 39 | + * @var Address |
|
| 40 | + */ |
|
| 41 | + protected $address_components = null; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 46 | - protected $formatted_address = null; |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | + protected $formatted_address = null; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var Geometry |
|
| 50 | - */ |
|
| 51 | - protected $geometry = null; |
|
| 48 | + /** |
|
| 49 | + * @var Geometry |
|
| 50 | + */ |
|
| 51 | + protected $geometry = null; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - protected $place_id = null; |
|
| 53 | + /** |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + protected $place_id = null; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @var array |
|
| 60 | - */ |
|
| 61 | - protected $types = null; |
|
| 58 | + /** |
|
| 59 | + * @var array |
|
| 60 | + */ |
|
| 61 | + protected $types = null; |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @var array |
|
| 65 | - */ |
|
| 66 | - protected $typeCheck = [ |
|
| 67 | - GoogleMapsResultFields::GEOMETRY => Geometry::class, |
|
| 68 | - GoogleMapsResultFields::ADDRESS_COMPONENTS => Address::class, |
|
| 69 | - GoogleMapsResultFields::FORMATTED_ADDRESS => 'string', |
|
| 70 | - GoogleMapsResultFields::PLACE_ID => 'string', |
|
| 71 | - GoogleMapsResultFields::TYPES => 'array' |
|
| 72 | - ]; |
|
| 63 | + /** |
|
| 64 | + * @var array |
|
| 65 | + */ |
|
| 66 | + protected $typeCheck = [ |
|
| 67 | + GoogleMapsResultFields::GEOMETRY => Geometry::class, |
|
| 68 | + GoogleMapsResultFields::ADDRESS_COMPONENTS => Address::class, |
|
| 69 | + GoogleMapsResultFields::FORMATTED_ADDRESS => 'string', |
|
| 70 | + GoogleMapsResultFields::PLACE_ID => 'string', |
|
| 71 | + GoogleMapsResultFields::TYPES => 'array' |
|
| 72 | + ]; |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @return Address |
|
| 76 | - */ |
|
| 77 | - public function getAddress(): Address |
|
| 78 | - { |
|
| 74 | + /** |
|
| 75 | + * @return Address |
|
| 76 | + */ |
|
| 77 | + public function getAddress(): Address |
|
| 78 | + { |
|
| 79 | 79 | |
| 80 | - return $this->getAddressComponents(); |
|
| 81 | - } |
|
| 80 | + return $this->getAddressComponents(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |
@@ -30,28 +30,28 @@ |
||
| 30 | 30 | class ElevationResult extends GoogleMapsResult |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var float |
|
| 35 | - */ |
|
| 36 | - protected $elevation = null; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var Location |
|
| 40 | - */ |
|
| 41 | - protected $location = null; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var float |
|
| 45 | - */ |
|
| 46 | - protected $resolution = null; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var array |
|
| 50 | - */ |
|
| 51 | - protected $typeCheck = [ |
|
| 52 | - GoogleMapsResultFields::LOCATION => Location::class, |
|
| 53 | - GoogleMapsResultFields::ELEVATION => 'float', |
|
| 54 | - GoogleMapsResultFields::RESOLUTION => 'float', |
|
| 55 | - ]; |
|
| 33 | + /** |
|
| 34 | + * @var float |
|
| 35 | + */ |
|
| 36 | + protected $elevation = null; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var Location |
|
| 40 | + */ |
|
| 41 | + protected $location = null; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var float |
|
| 45 | + */ |
|
| 46 | + protected $resolution = null; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var array |
|
| 50 | + */ |
|
| 51 | + protected $typeCheck = [ |
|
| 52 | + GoogleMapsResultFields::LOCATION => Location::class, |
|
| 53 | + GoogleMapsResultFields::ELEVATION => 'float', |
|
| 54 | + GoogleMapsResultFields::RESOLUTION => 'float', |
|
| 55 | + ]; |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -17,49 +17,49 @@ |
||
| 17 | 17 | class GoogleMapsClient |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var Client |
|
| 22 | - */ |
|
| 23 | - protected $client = null; |
|
| 20 | + /** |
|
| 21 | + * @var Client |
|
| 22 | + */ |
|
| 23 | + protected $client = null; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * GeocoderClient constructor. |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 25 | + /** |
|
| 26 | + * GeocoderClient constructor. |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | 30 | |
| 31 | - $this->setClient(new Client()); |
|
| 32 | - } |
|
| 31 | + $this->setClient(new Client()); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param null $client |
|
| 36 | - * |
|
| 37 | - * @return GoogleMapsClient |
|
| 38 | - */ |
|
| 39 | - public function setClient($client) |
|
| 40 | - { |
|
| 34 | + /** |
|
| 35 | + * @param null $client |
|
| 36 | + * |
|
| 37 | + * @return GoogleMapsClient |
|
| 38 | + */ |
|
| 39 | + public function setClient($client) |
|
| 40 | + { |
|
| 41 | 41 | |
| 42 | - $this->client = $client; |
|
| 42 | + $this->client = $client; |
|
| 43 | 43 | |
| 44 | - return $this; |
|
| 45 | - } |
|
| 44 | + return $this; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @param string $url |
|
| 49 | - * @param null|string $query |
|
| 50 | - * |
|
| 51 | - * @return \Biscolab\GoogleMaps\Http\GoogleMapsResponse |
|
| 52 | - */ |
|
| 53 | - public function get(string $url, ?string $query = null): GoogleMapsResponse |
|
| 54 | - { |
|
| 47 | + /** |
|
| 48 | + * @param string $url |
|
| 49 | + * @param null|string $query |
|
| 50 | + * |
|
| 51 | + * @return \Biscolab\GoogleMaps\Http\GoogleMapsResponse |
|
| 52 | + */ |
|
| 53 | + public function get(string $url, ?string $query = null): GoogleMapsResponse |
|
| 54 | + { |
|
| 55 | 55 | |
| 56 | - $client_params = $query ? [ |
|
| 57 | - 'query' => $query |
|
| 58 | - ] : null; |
|
| 56 | + $client_params = $query ? [ |
|
| 57 | + 'query' => $query |
|
| 58 | + ] : null; |
|
| 59 | 59 | |
| 60 | - /** @var Response $res */ |
|
| 61 | - $res = $this->client->request(GoogleMapsRequestMethodValues::GET, $url, $client_params); |
|
| 60 | + /** @var Response $res */ |
|
| 61 | + $res = $this->client->request(GoogleMapsRequestMethodValues::GET, $url, $client_params); |
|
| 62 | 62 | |
| 63 | - return new GoogleMapsResponse($res); |
|
| 64 | - } |
|
| 63 | + return new GoogleMapsResponse($res); |
|
| 64 | + } |
|
| 65 | 65 | } |
| 66 | 66 | \ No newline at end of file |