@@ -22,22 +22,22 @@ |
||
| 22 | 22 | class LatLngBounds extends AbstractObject |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var LatLng |
|
| 27 | - */ |
|
| 28 | - protected $northeast = null; |
|
| 25 | + /** |
|
| 26 | + * @var LatLng |
|
| 27 | + */ |
|
| 28 | + protected $northeast = null; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var LatLng |
|
| 32 | - */ |
|
| 33 | - protected $southwest = null; |
|
| 30 | + /** |
|
| 31 | + * @var LatLng |
|
| 32 | + */ |
|
| 33 | + protected $southwest = null; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - protected $typeCheck = [ |
|
| 39 | - LatLngBoundsFields::NORTHEAST => LatLng::class, |
|
| 40 | - LatLngBoundsFields::SOUTHWEST => LatLng::class |
|
| 41 | - ]; |
|
| 35 | + /** |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + protected $typeCheck = [ |
|
| 39 | + LatLngBoundsFields::NORTHEAST => LatLng::class, |
|
| 40 | + LatLngBoundsFields::SOUTHWEST => LatLng::class |
|
| 41 | + ]; |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | \ No newline at end of file |
@@ -21,14 +21,14 @@ |
||
| 21 | 21 | class Address extends AbstractCollection |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param $item |
|
| 26 | - * |
|
| 27 | - * @return AddressComponent |
|
| 28 | - */ |
|
| 29 | - protected function parseItem($item) |
|
| 30 | - { |
|
| 24 | + /** |
|
| 25 | + * @param $item |
|
| 26 | + * |
|
| 27 | + * @return AddressComponent |
|
| 28 | + */ |
|
| 29 | + protected function parseItem($item) |
|
| 30 | + { |
|
| 31 | 31 | |
| 32 | - return ($item instanceof AddressComponent) ? $item : new AddressComponent($item); |
|
| 33 | - } |
|
| 32 | + return ($item instanceof AddressComponent) ? $item : new AddressComponent($item); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -16,33 +16,33 @@ |
||
| 16 | 16 | class Photo extends AbstractObject |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var null|int |
|
| 21 | - */ |
|
| 22 | - protected $height = null; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var null|int |
|
| 26 | - */ |
|
| 27 | - protected $width = null; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var null|string |
|
| 31 | - */ |
|
| 32 | - protected $photo_reference = null; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var null|string |
|
| 36 | - */ |
|
| 37 | - protected $html_attributions = null; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - protected $typeCheck = [ |
|
| 43 | - PhotoFields::HEIGHT => 'int', |
|
| 44 | - PhotoFields::WIDTH => 'int', |
|
| 45 | - PhotoFields::PHOTO_REFERENCE => 'string', |
|
| 46 | - PhotoFields::HTML_ATTRIBUTIONS => 'array', |
|
| 47 | - ]; |
|
| 19 | + /** |
|
| 20 | + * @var null|int |
|
| 21 | + */ |
|
| 22 | + protected $height = null; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var null|int |
|
| 26 | + */ |
|
| 27 | + protected $width = null; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var null|string |
|
| 31 | + */ |
|
| 32 | + protected $photo_reference = null; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var null|string |
|
| 36 | + */ |
|
| 37 | + protected $html_attributions = null; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + protected $typeCheck = [ |
|
| 43 | + PhotoFields::HEIGHT => 'int', |
|
| 44 | + PhotoFields::WIDTH => 'int', |
|
| 45 | + PhotoFields::PHOTO_REFERENCE => 'string', |
|
| 46 | + PhotoFields::HTML_ATTRIBUTIONS => 'array', |
|
| 47 | + ]; |
|
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -26,27 +26,27 @@ |
||
| 26 | 26 | class AddressComponent extends AbstractObject |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - protected $long_name = null; |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + protected $long_name = null; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 37 | - protected $short_name = null; |
|
| 34 | + /** |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | + protected $short_name = null; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var array |
|
| 41 | - */ |
|
| 42 | - protected $types = null; |
|
| 39 | + /** |
|
| 40 | + * @var array |
|
| 41 | + */ |
|
| 42 | + protected $types = null; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var array |
|
| 46 | - */ |
|
| 47 | - protected $typeCheck = [ |
|
| 48 | - AddressComponentFields::LONG_NAME => 'string', |
|
| 49 | - AddressComponentFields::SHORT_NAME => 'string', |
|
| 50 | - AddressComponentFields::TYPES => 'array' |
|
| 51 | - ]; |
|
| 44 | + /** |
|
| 45 | + * @var array |
|
| 46 | + */ |
|
| 47 | + protected $typeCheck = [ |
|
| 48 | + AddressComponentFields::LONG_NAME => 'string', |
|
| 49 | + AddressComponentFields::SHORT_NAME => 'string', |
|
| 50 | + AddressComponentFields::TYPES => 'array' |
|
| 51 | + ]; |
|
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Config |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var int |
|
| 22 | - */ |
|
| 23 | - const MAX_PLACE_RADIUS_VALUE = 50000; |
|
| 20 | + /** |
|
| 21 | + * @var int |
|
| 22 | + */ |
|
| 23 | + const MAX_PLACE_RADIUS_VALUE = 50000; |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -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 |
@@ -21,37 +21,37 @@ |
||
| 21 | 21 | class Review extends AbstractObject |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var null|int |
|
| 26 | - */ |
|
| 27 | - protected $height = null; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var null|int |
|
| 31 | - */ |
|
| 32 | - protected $width = null; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var null|string |
|
| 36 | - */ |
|
| 37 | - protected $photo_reference = null; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var null|string |
|
| 41 | - */ |
|
| 42 | - protected $html_attributions = null; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var array |
|
| 46 | - */ |
|
| 47 | - protected $typeCheck = [ |
|
| 48 | - ReviewFields::AUTHOR_NAME => 'string', |
|
| 49 | - ReviewFields::AUTHOR_URL => 'string', |
|
| 50 | - ReviewFields::LANGUAGE => 'string', |
|
| 51 | - ReviewFields::PROFILE_PHOTO_URL => 'string', |
|
| 52 | - ReviewFields::RATING => 'int', |
|
| 53 | - ReviewFields::RELATIVE_TIME_DESCRIPTION => 'string', |
|
| 54 | - ReviewFields::TEXT => 'string', |
|
| 55 | - ReviewFields::TIME => 'int', |
|
| 56 | - ]; |
|
| 24 | + /** |
|
| 25 | + * @var null|int |
|
| 26 | + */ |
|
| 27 | + protected $height = null; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var null|int |
|
| 31 | + */ |
|
| 32 | + protected $width = null; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var null|string |
|
| 36 | + */ |
|
| 37 | + protected $photo_reference = null; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var null|string |
|
| 41 | + */ |
|
| 42 | + protected $html_attributions = null; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var array |
|
| 46 | + */ |
|
| 47 | + protected $typeCheck = [ |
|
| 48 | + ReviewFields::AUTHOR_NAME => 'string', |
|
| 49 | + ReviewFields::AUTHOR_URL => 'string', |
|
| 50 | + ReviewFields::LANGUAGE => 'string', |
|
| 51 | + ReviewFields::PROFILE_PHOTO_URL => 'string', |
|
| 52 | + ReviewFields::RATING => 'int', |
|
| 53 | + ReviewFields::RELATIVE_TIME_DESCRIPTION => 'string', |
|
| 54 | + ReviewFields::TEXT => 'string', |
|
| 55 | + ReviewFields::TIME => 'int', |
|
| 56 | + ]; |
|
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -20,19 +20,19 @@ |
||
| 20 | 20 | class ReviewCollection extends AbstractCollection |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected $item_class = Review::class; |
|
| 23 | + /** |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected $item_class = Review::class; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param $item |
|
| 30 | - * |
|
| 31 | - * @return Review |
|
| 32 | - */ |
|
| 33 | - protected function parseItem($item): Review |
|
| 34 | - { |
|
| 28 | + /** |
|
| 29 | + * @param $item |
|
| 30 | + * |
|
| 31 | + * @return Review |
|
| 32 | + */ |
|
| 33 | + protected function parseItem($item): Review |
|
| 34 | + { |
|
| 35 | 35 | |
| 36 | - return ($item instanceof $this->item_class) ? $item : new $this->item_class($item); |
|
| 37 | - } |
|
| 36 | + return ($item instanceof $this->item_class) ? $item : new $this->item_class($item); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -28,92 +28,92 @@ |
||
| 28 | 28 | class Elevation extends Api |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - const SERVICE_ENDPOINT = 'elevation'; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - protected $result_collection_type = ElevationResultsCollection::class; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Positional Requests |
|
| 43 | - * |
|
| 44 | - * @param LatLng|string|array $locations |
|
| 45 | - * This parameter takes either a single location or multiple locations passed as an array or as an encoded polyline |
|
| 46 | - * |
|
| 47 | - * @return GoogleMapsResultsCollection |
|
| 48 | - * |
|
| 49 | - * @since 0.3.0 |
|
| 50 | - */ |
|
| 51 | - public function getByLocations($locations): GoogleMapsResultsCollection |
|
| 52 | - { |
|
| 53 | - |
|
| 54 | - $locations = $this->parseLocations($locations); |
|
| 55 | - |
|
| 56 | - return $this->callApi([ |
|
| 57 | - GoogleMapsRequestFields::LOCATIONS => $locations |
|
| 58 | - ]); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @param array|string $locations |
|
| 63 | - * |
|
| 64 | - * @return string |
|
| 65 | - * |
|
| 66 | - * @since 0.3.0 |
|
| 67 | - */ |
|
| 68 | - public function parseLocations($locations): string |
|
| 69 | - { |
|
| 70 | - |
|
| 71 | - if ($locations instanceof Path) { |
|
| 72 | - $locations = $locations->toArray(); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if (is_array($locations)) { |
|
| 76 | - $locations = implode('|', array_map(function ($item) { |
|
| 77 | - |
|
| 78 | - return (string)$item; |
|
| 79 | - }, $locations)); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - return (string)$locations; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Sampled Path Requests |
|
| 87 | - * |
|
| 88 | - * @param array|string $path |
|
| 89 | - * This parameter takes either a multiple locations passed as an array or as an encoded polyline |
|
| 90 | - * |
|
| 91 | - * @param int $samples |
|
| 92 | - * This will be the number of results as well |
|
| 93 | - * |
|
| 94 | - * @throws InvalidArgumentException |
|
| 95 | - * @return GoogleMapsResultsCollection |
|
| 96 | - * |
|
| 97 | - * @since 0.4.0 |
|
| 98 | - */ |
|
| 99 | - public function getBySampledPath($path, int $samples): GoogleMapsResultsCollection |
|
| 100 | - { |
|
| 101 | - |
|
| 102 | - if ((is_array($path) && count($path) < 2) || |
|
| 103 | - $path instanceof Path && $path->count() < 2) { |
|
| 104 | - throw new InvalidArgumentException('The number of items provided in the path must be greater than 1 (One)'); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - if ($samples <= 0) { |
|
| 108 | - throw new InvalidArgumentException('The number of samples must be greater than 0 (Zero)'); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $path = $this->parseLocations($path); |
|
| 112 | - |
|
| 113 | - return $this->callApi([ |
|
| 114 | - GoogleMapsRequestFields::PATH => $path, |
|
| 115 | - GoogleMapsRequestFields::SAMPLES => $samples, |
|
| 116 | - ]); |
|
| 117 | - } |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + const SERVICE_ENDPOINT = 'elevation'; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + protected $result_collection_type = ElevationResultsCollection::class; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Positional Requests |
|
| 43 | + * |
|
| 44 | + * @param LatLng|string|array $locations |
|
| 45 | + * This parameter takes either a single location or multiple locations passed as an array or as an encoded polyline |
|
| 46 | + * |
|
| 47 | + * @return GoogleMapsResultsCollection |
|
| 48 | + * |
|
| 49 | + * @since 0.3.0 |
|
| 50 | + */ |
|
| 51 | + public function getByLocations($locations): GoogleMapsResultsCollection |
|
| 52 | + { |
|
| 53 | + |
|
| 54 | + $locations = $this->parseLocations($locations); |
|
| 55 | + |
|
| 56 | + return $this->callApi([ |
|
| 57 | + GoogleMapsRequestFields::LOCATIONS => $locations |
|
| 58 | + ]); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @param array|string $locations |
|
| 63 | + * |
|
| 64 | + * @return string |
|
| 65 | + * |
|
| 66 | + * @since 0.3.0 |
|
| 67 | + */ |
|
| 68 | + public function parseLocations($locations): string |
|
| 69 | + { |
|
| 70 | + |
|
| 71 | + if ($locations instanceof Path) { |
|
| 72 | + $locations = $locations->toArray(); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if (is_array($locations)) { |
|
| 76 | + $locations = implode('|', array_map(function ($item) { |
|
| 77 | + |
|
| 78 | + return (string)$item; |
|
| 79 | + }, $locations)); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + return (string)$locations; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Sampled Path Requests |
|
| 87 | + * |
|
| 88 | + * @param array|string $path |
|
| 89 | + * This parameter takes either a multiple locations passed as an array or as an encoded polyline |
|
| 90 | + * |
|
| 91 | + * @param int $samples |
|
| 92 | + * This will be the number of results as well |
|
| 93 | + * |
|
| 94 | + * @throws InvalidArgumentException |
|
| 95 | + * @return GoogleMapsResultsCollection |
|
| 96 | + * |
|
| 97 | + * @since 0.4.0 |
|
| 98 | + */ |
|
| 99 | + public function getBySampledPath($path, int $samples): GoogleMapsResultsCollection |
|
| 100 | + { |
|
| 101 | + |
|
| 102 | + if ((is_array($path) && count($path) < 2) || |
|
| 103 | + $path instanceof Path && $path->count() < 2) { |
|
| 104 | + throw new InvalidArgumentException('The number of items provided in the path must be greater than 1 (One)'); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + if ($samples <= 0) { |
|
| 108 | + throw new InvalidArgumentException('The number of samples must be greater than 0 (Zero)'); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $path = $this->parseLocations($path); |
|
| 112 | + |
|
| 113 | + return $this->callApi([ |
|
| 114 | + GoogleMapsRequestFields::PATH => $path, |
|
| 115 | + GoogleMapsRequestFields::SAMPLES => $samples, |
|
| 116 | + ]); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |