|
11 | 11 | namespace Biscolab\GoogleMaps\Api; |
12 | 12 |
|
13 | 13 | use Biscolab\GoogleMaps\Abstracts\Api; |
14 | | -use Biscolab\GoogleMaps\Config\Util; |
15 | 14 | use Biscolab\GoogleMaps\Enum\PlaceServicesEndpoints; |
16 | 15 | use Biscolab\GoogleMaps\Exception\InvalidArgumentException; |
17 | 16 | use Biscolab\GoogleMaps\Fields\GoogleMapsRequestFields; |
18 | 17 | use Biscolab\GoogleMaps\Fields\GoogleMapsResultFields; |
19 | 18 | use Biscolab\GoogleMaps\Http\GoogleMapsResultsCollection; |
20 | 19 | use Biscolab\GoogleMaps\Http\Result\PlaceResultsCollection; |
21 | 20 | use Biscolab\GoogleMaps\Object\Location; |
| 21 | +use Biscolab\GoogleMaps\Utils\Config; |
22 | 22 | use Biscolab\GoogleMaps\Values\PlaceInputTypeValues; |
23 | 23 | use Biscolab\GoogleMaps\Values\RankByValues; |
24 | 24 |
|
@@ -134,29 +134,15 @@ public function findPlaceByPhoneNumber( |
134 | 134 | * |
135 | 135 | * @return GoogleMapsResultsCollection |
136 | 136 | */ |
137 | | - public function findNearbyPlaceByRadius(Location $location, int $radius, ?array $params = []): GoogleMapsResultsCollection |
138 | | - { |
139 | | - |
140 | | - $params = array_merge($params, [ |
141 | | - GoogleMapsRequestFields::LOCATION => $location, |
142 | | - GoogleMapsRequestFields::RADIUS => $radius |
143 | | - ]); |
144 | | - |
145 | | - return $this->findNearbyPlace($params); |
146 | | - } |
147 | | - |
148 | | - /** |
149 | | - * @param Location $location |
150 | | - * @param array $params |
151 | | - * |
152 | | - * @return GoogleMapsResultsCollection |
153 | | - */ |
154 | | - public function findNearbyPlaceByDistance(Location $location, array $params): GoogleMapsResultsCollection |
155 | | - { |
| 137 | + public function findNearbyPlaceByRadius( |
| 138 | + Location $location, |
| 139 | + int $radius, |
| 140 | + ?array $params = [] |
| 141 | + ): GoogleMapsResultsCollection { |
156 | 142 |
|
157 | 143 | $params = array_merge($params, [ |
158 | 144 | GoogleMapsRequestFields::LOCATION => $location, |
159 | | - GoogleMapsRequestFields::RANKBY => RankByValues::DISTANCE |
| 145 | + GoogleMapsRequestFields::RADIUS => $radius |
160 | 146 | ]); |
161 | 147 |
|
162 | 148 | return $this->findNearbyPlace($params); |
@@ -205,14 +191,31 @@ public function findNearbyPlace(array $params): GoogleMapsResultsCollection |
205 | 191 | throw new InvalidArgumentException(GoogleMapsRequestFields::RADIUS . ' field is required'); |
206 | 192 | } |
207 | 193 |
|
208 | | - if (!empty($params[GoogleMapsRequestFields::RADIUS]) && floatval($params[GoogleMapsRequestFields::RADIUS]) > Util::MAX_PLACE_RADIUS_VALUE) { |
| 194 | + if (!empty($params[GoogleMapsRequestFields::RADIUS]) && floatval($params[GoogleMapsRequestFields::RADIUS]) > Config::MAX_PLACE_RADIUS_VALUE) { |
209 | 195 | // The maximum allowed radius is 50 000 meters. |
210 | | - throw new InvalidArgumentException(GoogleMapsRequestFields::RADIUS . ' must be lower than ' . Util::MAX_PLACE_RADIUS_VALUE); |
| 196 | + throw new InvalidArgumentException(GoogleMapsRequestFields::RADIUS . ' must be lower than ' . Config::MAX_PLACE_RADIUS_VALUE); |
211 | 197 | } |
212 | 198 |
|
213 | 199 | return $this->makeApiCall($params, PlaceServicesEndpoints::NEARBYSEARCH); |
214 | 200 | } |
215 | 201 |
|
| 202 | + /** |
| 203 | + * @param Location $location |
| 204 | + * @param array $params |
| 205 | + * |
| 206 | + * @return GoogleMapsResultsCollection |
| 207 | + */ |
| 208 | + public function findNearbyPlaceByDistance(Location $location, array $params): GoogleMapsResultsCollection |
| 209 | + { |
| 210 | + |
| 211 | + $params = array_merge($params, [ |
| 212 | + GoogleMapsRequestFields::LOCATION => $location, |
| 213 | + GoogleMapsRequestFields::RANKBY => RankByValues::DISTANCE |
| 214 | + ]); |
| 215 | + |
| 216 | + return $this->findNearbyPlace($params); |
| 217 | + } |
| 218 | + |
216 | 219 | /** |
217 | 220 | * Nearby Search requests |
218 | 221 | * |
|
0 commit comments