@@ -17,80 +17,80 @@ |
||
| 17 | 17 | class GoogleMapsRequest |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - * @since 0.5.0 |
|
| 23 | - */ |
|
| 24 | - protected $endpoint = null; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - private $params = []; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * GoogleMapsRequest constructor. |
|
| 33 | - * |
|
| 34 | - * @param array $params |
|
| 35 | - * @param null|string $endpoint |
|
| 36 | - */ |
|
| 37 | - public function __construct(array $params = [], ?string $endpoint = null) |
|
| 38 | - { |
|
| 39 | - |
|
| 40 | - if ($params) { |
|
| 41 | - foreach ($params as $param_name => $param_value) { |
|
| 42 | - $this->setParam($param_name, $param_value); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - $this->endpoint = $endpoint; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param string $param_name |
|
| 51 | - * @param mixed $param_value |
|
| 52 | - * |
|
| 53 | - * @return GoogleMapsRequest |
|
| 54 | - */ |
|
| 55 | - public function setParam(string $param_name, $param_value): GoogleMapsRequest |
|
| 56 | - { |
|
| 57 | - |
|
| 58 | - $this->params[$param_name] = $param_value; |
|
| 59 | - |
|
| 60 | - return $this; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @return string |
|
| 65 | - */ |
|
| 66 | - public function getQuery(): string |
|
| 67 | - { |
|
| 68 | - |
|
| 69 | - $params = []; |
|
| 70 | - |
|
| 71 | - foreach ($this->params as $param_name => $param_value) { |
|
| 72 | - $params[$param_name] = (string)$param_value; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return http_build_query($params); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @return array |
|
| 80 | - */ |
|
| 81 | - public function getParams(): array |
|
| 82 | - { |
|
| 83 | - |
|
| 84 | - return $this->params; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @return null|string |
|
| 89 | - */ |
|
| 90 | - public function getEndpoint(): ?string |
|
| 91 | - { |
|
| 92 | - |
|
| 93 | - return $this->endpoint; |
|
| 94 | - } |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + * @since 0.5.0 |
|
| 23 | + */ |
|
| 24 | + protected $endpoint = null; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + private $params = []; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * GoogleMapsRequest constructor. |
|
| 33 | + * |
|
| 34 | + * @param array $params |
|
| 35 | + * @param null|string $endpoint |
|
| 36 | + */ |
|
| 37 | + public function __construct(array $params = [], ?string $endpoint = null) |
|
| 38 | + { |
|
| 39 | + |
|
| 40 | + if ($params) { |
|
| 41 | + foreach ($params as $param_name => $param_value) { |
|
| 42 | + $this->setParam($param_name, $param_value); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + $this->endpoint = $endpoint; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param string $param_name |
|
| 51 | + * @param mixed $param_value |
|
| 52 | + * |
|
| 53 | + * @return GoogleMapsRequest |
|
| 54 | + */ |
|
| 55 | + public function setParam(string $param_name, $param_value): GoogleMapsRequest |
|
| 56 | + { |
|
| 57 | + |
|
| 58 | + $this->params[$param_name] = $param_value; |
|
| 59 | + |
|
| 60 | + return $this; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @return string |
|
| 65 | + */ |
|
| 66 | + public function getQuery(): string |
|
| 67 | + { |
|
| 68 | + |
|
| 69 | + $params = []; |
|
| 70 | + |
|
| 71 | + foreach ($this->params as $param_name => $param_value) { |
|
| 72 | + $params[$param_name] = (string)$param_value; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return http_build_query($params); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @return array |
|
| 80 | + */ |
|
| 81 | + public function getParams(): array |
|
| 82 | + { |
|
| 83 | + |
|
| 84 | + return $this->params; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @return null|string |
|
| 89 | + */ |
|
| 90 | + public function getEndpoint(): ?string |
|
| 91 | + { |
|
| 92 | + |
|
| 93 | + return $this->endpoint; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | \ 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 |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | class GoogleMapsResultsCollection extends AbstractCollection |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - protected $item_class = GoogleMapsResult::class; |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + protected $item_class = GoogleMapsResult::class; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param $item |
|
| 29 | - * |
|
| 30 | - * @return GoogleMapsResult |
|
| 31 | - */ |
|
| 32 | - protected function parseItem($item): GoogleMapsResult |
|
| 33 | - { |
|
| 27 | + /** |
|
| 28 | + * @param $item |
|
| 29 | + * |
|
| 30 | + * @return GoogleMapsResult |
|
| 31 | + */ |
|
| 32 | + protected function parseItem($item): GoogleMapsResult |
|
| 33 | + { |
|
| 34 | 34 | |
| 35 | - $item_class = $this->item_class; |
|
| 35 | + $item_class = $this->item_class; |
|
| 36 | 36 | |
| 37 | - return new $item_class($item); |
|
| 38 | - } |
|
| 37 | + return new $item_class($item); |
|
| 38 | + } |
|
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | class PlaceInputTypeValues |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - const TEXTQUERY = "textquery"; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + const TEXTQUERY = "textquery"; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - const PHONENUMBER = "phonenumber"; |
|
| 25 | + /** |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + const PHONENUMBER = "phonenumber"; |
|
| 29 | 29 | } |
| 30 | 30 | \ No newline at end of file |