@@ -21,184 +21,184 @@ |
||
| 21 | 21 | abstract class AbstractObject |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - protected $typeCheck = []; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - protected $required = []; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var array |
|
| 36 | - */ |
|
| 37 | - protected $errors = []; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * AbstractObject constructor. |
|
| 41 | - * |
|
| 42 | - * @param array $args |
|
| 43 | - */ |
|
| 44 | - public function __construct(?array $args = []) |
|
| 45 | - { |
|
| 46 | - |
|
| 47 | - if (is_null($args)) { |
|
| 48 | - $args = []; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $this->setArgs($args); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param array $args |
|
| 56 | - * |
|
| 57 | - * @throws Exception |
|
| 58 | - */ |
|
| 59 | - protected function setArgs(array $args) |
|
| 60 | - { |
|
| 61 | - |
|
| 62 | - foreach ($this->typeCheck as $field_name => $field_type) { |
|
| 63 | - if (empty($args[$field_name]) || is_null($args[$field_name])) { |
|
| 64 | - if ($this->isFieldRequired($field_name)) { |
|
| 65 | - $this->addError('Missing "' . $field_name . '" in ' . static::class); |
|
| 66 | - } |
|
| 67 | - } else { |
|
| 68 | - $this->$field_name = $this->parseFieldValue($field_type, $args[$field_name]); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - $this->throwErrors(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @param string $field_name |
|
| 76 | - * |
|
| 77 | - * @return bool |
|
| 78 | - */ |
|
| 79 | - protected function isFieldRequired(string $field_name): bool |
|
| 80 | - { |
|
| 81 | - |
|
| 82 | - return in_array($field_name, $this->required); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param string $error |
|
| 87 | - * |
|
| 88 | - * @return array |
|
| 89 | - */ |
|
| 90 | - protected function addError(string $error): array |
|
| 91 | - { |
|
| 92 | - |
|
| 93 | - array_push($this->errors, $error); |
|
| 94 | - |
|
| 95 | - return $this->errors; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @param string $field_type |
|
| 100 | - * @param string $field_value |
|
| 101 | - * |
|
| 102 | - * @return mixed |
|
| 103 | - */ |
|
| 104 | - protected function parseFieldValue(string $field_type, $field_value) |
|
| 105 | - { |
|
| 106 | - |
|
| 107 | - switch ($field_type) { |
|
| 108 | - case 'string': |
|
| 109 | - case 'int': |
|
| 110 | - case 'float': |
|
| 111 | - case 'array': |
|
| 112 | - case 'json': |
|
| 113 | - case 'bool': |
|
| 114 | - return $field_value; |
|
| 115 | - default: |
|
| 116 | - return ($field_value instanceof $field_type) ? $field_value : new $field_type($field_value); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @throws Exception |
|
| 122 | - */ |
|
| 123 | - protected function throwErrors() |
|
| 124 | - { |
|
| 125 | - |
|
| 126 | - if (count($this->errors)) { |
|
| 127 | - throw new Exception(implode(', ', $this->errors)); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function toJson(): string |
|
| 135 | - { |
|
| 136 | - |
|
| 137 | - return json_encode($this->toArray()); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * @return array |
|
| 142 | - */ |
|
| 143 | - public function toArray(): array |
|
| 144 | - { |
|
| 145 | - |
|
| 146 | - $fields = get_object_vars($this); |
|
| 147 | - |
|
| 148 | - foreach ($fields as $field_name => $field_value) { |
|
| 149 | - |
|
| 150 | - if (!is_scalar($field_value) && method_exists($field_value, 'toJson')) { |
|
| 151 | - $fields[$field_name] = $field_value->toArray(); |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - return $fields; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @return string |
|
| 160 | - */ |
|
| 161 | - public function __toString(): string |
|
| 162 | - { |
|
| 163 | - |
|
| 164 | - return implode(',', $this->toArray()); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @param $name |
|
| 169 | - * @param $arguments |
|
| 170 | - * |
|
| 171 | - * @return mixed |
|
| 172 | - */ |
|
| 173 | - public function __call($name, $arguments) |
|
| 174 | - { |
|
| 175 | - |
|
| 176 | - preg_match('/(?<=(g|s)et)([A-Za-z0-9])\w+/', $name, $match); |
|
| 177 | - |
|
| 178 | - $camel_field = (empty($match[0])) ? '' : $match[0]; |
|
| 179 | - |
|
| 180 | - $snake_field = $this->getFieldName($camel_field); |
|
| 181 | - |
|
| 182 | - $field_type = (empty($this->typeCheck[$snake_field])) ? null : $this->typeCheck[$snake_field]; |
|
| 183 | - |
|
| 184 | - if (!empty($match[1]) && $field_type) { |
|
| 185 | - switch ($match[1]) { |
|
| 186 | - case 's': |
|
| 187 | - return $this->$snake_field = $this->parseFieldValue($field_type, current($arguments)); |
|
| 188 | - case 'g': |
|
| 189 | - return $this->$snake_field; |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * @param string $initial_field_name |
|
| 196 | - * |
|
| 197 | - * @return string |
|
| 198 | - */ |
|
| 199 | - protected function getFieldName(string $initial_field_name): string |
|
| 200 | - { |
|
| 201 | - |
|
| 202 | - return camel2Snake($initial_field_name); |
|
| 203 | - } |
|
| 24 | + /** |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + protected $typeCheck = []; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + protected $required = []; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var array |
|
| 36 | + */ |
|
| 37 | + protected $errors = []; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * AbstractObject constructor. |
|
| 41 | + * |
|
| 42 | + * @param array $args |
|
| 43 | + */ |
|
| 44 | + public function __construct(?array $args = []) |
|
| 45 | + { |
|
| 46 | + |
|
| 47 | + if (is_null($args)) { |
|
| 48 | + $args = []; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $this->setArgs($args); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param array $args |
|
| 56 | + * |
|
| 57 | + * @throws Exception |
|
| 58 | + */ |
|
| 59 | + protected function setArgs(array $args) |
|
| 60 | + { |
|
| 61 | + |
|
| 62 | + foreach ($this->typeCheck as $field_name => $field_type) { |
|
| 63 | + if (empty($args[$field_name]) || is_null($args[$field_name])) { |
|
| 64 | + if ($this->isFieldRequired($field_name)) { |
|
| 65 | + $this->addError('Missing "' . $field_name . '" in ' . static::class); |
|
| 66 | + } |
|
| 67 | + } else { |
|
| 68 | + $this->$field_name = $this->parseFieldValue($field_type, $args[$field_name]); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + $this->throwErrors(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @param string $field_name |
|
| 76 | + * |
|
| 77 | + * @return bool |
|
| 78 | + */ |
|
| 79 | + protected function isFieldRequired(string $field_name): bool |
|
| 80 | + { |
|
| 81 | + |
|
| 82 | + return in_array($field_name, $this->required); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param string $error |
|
| 87 | + * |
|
| 88 | + * @return array |
|
| 89 | + */ |
|
| 90 | + protected function addError(string $error): array |
|
| 91 | + { |
|
| 92 | + |
|
| 93 | + array_push($this->errors, $error); |
|
| 94 | + |
|
| 95 | + return $this->errors; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @param string $field_type |
|
| 100 | + * @param string $field_value |
|
| 101 | + * |
|
| 102 | + * @return mixed |
|
| 103 | + */ |
|
| 104 | + protected function parseFieldValue(string $field_type, $field_value) |
|
| 105 | + { |
|
| 106 | + |
|
| 107 | + switch ($field_type) { |
|
| 108 | + case 'string': |
|
| 109 | + case 'int': |
|
| 110 | + case 'float': |
|
| 111 | + case 'array': |
|
| 112 | + case 'json': |
|
| 113 | + case 'bool': |
|
| 114 | + return $field_value; |
|
| 115 | + default: |
|
| 116 | + return ($field_value instanceof $field_type) ? $field_value : new $field_type($field_value); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @throws Exception |
|
| 122 | + */ |
|
| 123 | + protected function throwErrors() |
|
| 124 | + { |
|
| 125 | + |
|
| 126 | + if (count($this->errors)) { |
|
| 127 | + throw new Exception(implode(', ', $this->errors)); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function toJson(): string |
|
| 135 | + { |
|
| 136 | + |
|
| 137 | + return json_encode($this->toArray()); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * @return array |
|
| 142 | + */ |
|
| 143 | + public function toArray(): array |
|
| 144 | + { |
|
| 145 | + |
|
| 146 | + $fields = get_object_vars($this); |
|
| 147 | + |
|
| 148 | + foreach ($fields as $field_name => $field_value) { |
|
| 149 | + |
|
| 150 | + if (!is_scalar($field_value) && method_exists($field_value, 'toJson')) { |
|
| 151 | + $fields[$field_name] = $field_value->toArray(); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + return $fields; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @return string |
|
| 160 | + */ |
|
| 161 | + public function __toString(): string |
|
| 162 | + { |
|
| 163 | + |
|
| 164 | + return implode(',', $this->toArray()); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @param $name |
|
| 169 | + * @param $arguments |
|
| 170 | + * |
|
| 171 | + * @return mixed |
|
| 172 | + */ |
|
| 173 | + public function __call($name, $arguments) |
|
| 174 | + { |
|
| 175 | + |
|
| 176 | + preg_match('/(?<=(g|s)et)([A-Za-z0-9])\w+/', $name, $match); |
|
| 177 | + |
|
| 178 | + $camel_field = (empty($match[0])) ? '' : $match[0]; |
|
| 179 | + |
|
| 180 | + $snake_field = $this->getFieldName($camel_field); |
|
| 181 | + |
|
| 182 | + $field_type = (empty($this->typeCheck[$snake_field])) ? null : $this->typeCheck[$snake_field]; |
|
| 183 | + |
|
| 184 | + if (!empty($match[1]) && $field_type) { |
|
| 185 | + switch ($match[1]) { |
|
| 186 | + case 's': |
|
| 187 | + return $this->$snake_field = $this->parseFieldValue($field_type, current($arguments)); |
|
| 188 | + case 'g': |
|
| 189 | + return $this->$snake_field; |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * @param string $initial_field_name |
|
| 196 | + * |
|
| 197 | + * @return string |
|
| 198 | + */ |
|
| 199 | + protected function getFieldName(string $initial_field_name): string |
|
| 200 | + { |
|
| 201 | + |
|
| 202 | + return camel2Snake($initial_field_name); |
|
| 203 | + } |
|
| 204 | 204 | } |
@@ -27,35 +27,35 @@ |
||
| 27 | 27 | class TimeZone extends Api |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - const SERVICE_ENDPOINT = 'timezone'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - protected $result_type = TimeZoneResult::class; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param Location $location |
|
| 42 | - * @param int $timestamp |
|
| 43 | - * @param string|null $language |
|
| 44 | - * |
|
| 45 | - * @return GoogleMapsResult |
|
| 46 | - */ |
|
| 47 | - public function get(Location $location, int $timestamp, string $language = null): GoogleMapsResult |
|
| 48 | - { |
|
| 49 | - |
|
| 50 | - $params = [ |
|
| 51 | - GoogleMapsRequestFields::LOCATION => $location, |
|
| 52 | - GoogleMapsRequestFields::TIMESTAMP => $timestamp, |
|
| 53 | - ]; |
|
| 54 | - |
|
| 55 | - if ($language) { |
|
| 56 | - $params[GoogleMapsRequestFields::LANGUAGE] = $language; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - return $this->callApi($params); |
|
| 60 | - } |
|
| 30 | + /** |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + const SERVICE_ENDPOINT = 'timezone'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + protected $result_type = TimeZoneResult::class; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param Location $location |
|
| 42 | + * @param int $timestamp |
|
| 43 | + * @param string|null $language |
|
| 44 | + * |
|
| 45 | + * @return GoogleMapsResult |
|
| 46 | + */ |
|
| 47 | + public function get(Location $location, int $timestamp, string $language = null): GoogleMapsResult |
|
| 48 | + { |
|
| 49 | + |
|
| 50 | + $params = [ |
|
| 51 | + GoogleMapsRequestFields::LOCATION => $location, |
|
| 52 | + GoogleMapsRequestFields::TIMESTAMP => $timestamp, |
|
| 53 | + ]; |
|
| 54 | + |
|
| 55 | + if ($language) { |
|
| 56 | + $params[GoogleMapsRequestFields::LANGUAGE] = $language; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + return $this->callApi($params); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -26,112 +26,112 @@ |
||
| 26 | 26 | class Geocoding extends Api |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * The language in which to return results |
|
| 31 | - * https://developers.google.com/maps/faq#languagesupport |
|
| 32 | - * |
|
| 33 | - * @var null|string |
|
| 34 | - */ |
|
| 35 | - private $language = null; |
|
| 29 | + /** |
|
| 30 | + * The language in which to return results |
|
| 31 | + * https://developers.google.com/maps/faq#languagesupport |
|
| 32 | + * |
|
| 33 | + * @var null|string |
|
| 34 | + */ |
|
| 35 | + private $language = null; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - const SERVICE_ENDPOINT = 'geocode'; |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + const SERVICE_ENDPOINT = 'geocode'; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - protected $result_collection_type = GeocodingResultsCollection::class; |
|
| 42 | + /** |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + protected $result_collection_type = GeocodingResultsCollection::class; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Set the language in which to return results |
|
| 49 | - * |
|
| 50 | - * @param null|string $language |
|
| 51 | - * @return self |
|
| 52 | - */ |
|
| 53 | - public function setLanguage(?string $language = null): self |
|
| 54 | - { |
|
| 55 | - $this->language = $language; |
|
| 56 | - return $this; |
|
| 57 | - } |
|
| 47 | + /** |
|
| 48 | + * Set the language in which to return results |
|
| 49 | + * |
|
| 50 | + * @param null|string $language |
|
| 51 | + * @return self |
|
| 52 | + */ |
|
| 53 | + public function setLanguage(?string $language = null): self |
|
| 54 | + { |
|
| 55 | + $this->language = $language; |
|
| 56 | + return $this; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Add language to $params list if necessary |
|
| 61 | - * |
|
| 62 | - * @param array $params |
|
| 63 | - * @return array |
|
| 64 | - * @since 0.8.0 |
|
| 65 | - */ |
|
| 66 | - public function prepareParams(array $params): array |
|
| 67 | - { |
|
| 68 | - if ($this->language) { |
|
| 69 | - $params[GoogleMapsRequestFields::LANGUAGE] = $this->language; |
|
| 70 | - } |
|
| 71 | - return $params; |
|
| 72 | - } |
|
| 59 | + /** |
|
| 60 | + * Add language to $params list if necessary |
|
| 61 | + * |
|
| 62 | + * @param array $params |
|
| 63 | + * @return array |
|
| 64 | + * @since 0.8.0 |
|
| 65 | + */ |
|
| 66 | + public function prepareParams(array $params): array |
|
| 67 | + { |
|
| 68 | + if ($this->language) { |
|
| 69 | + $params[GoogleMapsRequestFields::LANGUAGE] = $this->language; |
|
| 70 | + } |
|
| 71 | + return $params; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Geocoding (Address Lookup) |
|
| 76 | - * |
|
| 77 | - * @param string $literal_address |
|
| 78 | - * @param string $region |
|
| 79 | - * |
|
| 80 | - * @return GoogleMapsResultsCollection |
|
| 81 | - */ |
|
| 82 | - public function getByAddress(string $literal_address, ?string $region = null): GoogleMapsResultsCollection |
|
| 83 | - { |
|
| 84 | - $params = [ |
|
| 85 | - GoogleMapsRequestFields::ADDRESS => $literal_address |
|
| 86 | - ]; |
|
| 87 | - if ($region) { |
|
| 88 | - $params[GoogleMapsRequestFields::REGION] = $region; |
|
| 89 | - } |
|
| 90 | - $params = $this->prepareParams($params); |
|
| 91 | - return $this->callApi($params); |
|
| 92 | - } |
|
| 74 | + /** |
|
| 75 | + * Geocoding (Address Lookup) |
|
| 76 | + * |
|
| 77 | + * @param string $literal_address |
|
| 78 | + * @param string $region |
|
| 79 | + * |
|
| 80 | + * @return GoogleMapsResultsCollection |
|
| 81 | + */ |
|
| 82 | + public function getByAddress(string $literal_address, ?string $region = null): GoogleMapsResultsCollection |
|
| 83 | + { |
|
| 84 | + $params = [ |
|
| 85 | + GoogleMapsRequestFields::ADDRESS => $literal_address |
|
| 86 | + ]; |
|
| 87 | + if ($region) { |
|
| 88 | + $params[GoogleMapsRequestFields::REGION] = $region; |
|
| 89 | + } |
|
| 90 | + $params = $this->prepareParams($params); |
|
| 91 | + return $this->callApi($params); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * ALIAS: getByLatLng |
|
| 96 | - * Geocoding (Latitude/Longitude Lookup) |
|
| 97 | - * |
|
| 98 | - * @param LatLng $latlng |
|
| 99 | - * |
|
| 100 | - * @return GoogleMapsResultsCollection |
|
| 101 | - * @deprecated 0.8.0 |
|
| 102 | - */ |
|
| 103 | - public function getReverse(LatLng $latlng): GoogleMapsResultsCollection |
|
| 104 | - { |
|
| 105 | - return $this->getByLatLng($latlng); |
|
| 106 | - } |
|
| 94 | + /** |
|
| 95 | + * ALIAS: getByLatLng |
|
| 96 | + * Geocoding (Latitude/Longitude Lookup) |
|
| 97 | + * |
|
| 98 | + * @param LatLng $latlng |
|
| 99 | + * |
|
| 100 | + * @return GoogleMapsResultsCollection |
|
| 101 | + * @deprecated 0.8.0 |
|
| 102 | + */ |
|
| 103 | + public function getReverse(LatLng $latlng): GoogleMapsResultsCollection |
|
| 104 | + { |
|
| 105 | + return $this->getByLatLng($latlng); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Geocoding (Latitude/Longitude Lookup) |
|
| 110 | - * |
|
| 111 | - * @param LatLng $latlng |
|
| 112 | - * |
|
| 113 | - * @return GoogleMapsResultsCollection |
|
| 114 | - * @since 0.8.0 |
|
| 115 | - */ |
|
| 116 | - public function getByLatLng(LatLng $latlng): GoogleMapsResultsCollection |
|
| 117 | - { |
|
| 118 | - $params = $this->prepareParams([ |
|
| 119 | - GoogleMapsRequestFields::LATLNG => $latlng |
|
| 120 | - ]); |
|
| 121 | - return $this->callApi($params); |
|
| 122 | - } |
|
| 108 | + /** |
|
| 109 | + * Geocoding (Latitude/Longitude Lookup) |
|
| 110 | + * |
|
| 111 | + * @param LatLng $latlng |
|
| 112 | + * |
|
| 113 | + * @return GoogleMapsResultsCollection |
|
| 114 | + * @since 0.8.0 |
|
| 115 | + */ |
|
| 116 | + public function getByLatLng(LatLng $latlng): GoogleMapsResultsCollection |
|
| 117 | + { |
|
| 118 | + $params = $this->prepareParams([ |
|
| 119 | + GoogleMapsRequestFields::LATLNG => $latlng |
|
| 120 | + ]); |
|
| 121 | + return $this->callApi($params); |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Retrieving an Address for a Place ID |
|
| 126 | - * |
|
| 127 | - * @param string $place_id |
|
| 128 | - * |
|
| 129 | - * @return GoogleMapsResultsCollection |
|
| 130 | - */ |
|
| 131 | - public function getByPlaceId(string $place_id): GoogleMapsResultsCollection |
|
| 132 | - { |
|
| 133 | - return $this->callApi([ |
|
| 134 | - GoogleMapsRequestFields::PLACE_ID => $place_id |
|
| 135 | - ]); |
|
| 136 | - } |
|
| 124 | + /** |
|
| 125 | + * Retrieving an Address for a Place ID |
|
| 126 | + * |
|
| 127 | + * @param string $place_id |
|
| 128 | + * |
|
| 129 | + * @return GoogleMapsResultsCollection |
|
| 130 | + */ |
|
| 131 | + public function getByPlaceId(string $place_id): GoogleMapsResultsCollection |
|
| 132 | + { |
|
| 133 | + return $this->callApi([ |
|
| 134 | + GoogleMapsRequestFields::PLACE_ID => $place_id |
|
| 135 | + ]); |
|
| 136 | + } |
|
| 137 | 137 | } |
@@ -18,175 +18,175 @@ |
||
| 18 | 18 | class GoogleMapsRequestFields |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var string key |
|
| 23 | - */ |
|
| 24 | - const KEY = 'key'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var string sensor |
|
| 28 | - */ |
|
| 29 | - const SENSOR = 'sensor'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var string latlng |
|
| 33 | - */ |
|
| 34 | - const LATLNG = 'latlng'; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string address |
|
| 38 | - */ |
|
| 39 | - const ADDRESS = 'address'; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var string place_id |
|
| 43 | - */ |
|
| 44 | - const PLACE_ID = 'place_id'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string location |
|
| 48 | - * @since 0.5.0 |
|
| 49 | - */ |
|
| 50 | - const LOCATION = 'location'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var string locations |
|
| 54 | - */ |
|
| 55 | - const LOCATIONS = 'locations'; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var string path |
|
| 59 | - */ |
|
| 60 | - const PATH = 'path'; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var string samples |
|
| 64 | - */ |
|
| 65 | - const SAMPLES = 'samples'; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var string input |
|
| 69 | - * @since 0.5.0 |
|
| 70 | - */ |
|
| 71 | - const INPUT = 'input'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @var string inputtype |
|
| 75 | - * @since 0.5.0 |
|
| 76 | - */ |
|
| 77 | - const INPUTTYPE = 'inputtype'; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @var string language |
|
| 81 | - * @since 0.5.0 |
|
| 82 | - */ |
|
| 83 | - const LANGUAGE = 'language'; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @var string fields |
|
| 87 | - * @since 0.5.0 |
|
| 88 | - */ |
|
| 89 | - const FIELDS = 'fields'; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @var string locationbias |
|
| 93 | - * @since 0.5.0 |
|
| 94 | - */ |
|
| 95 | - const LOCATIONBIAS = 'locationbias'; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @var string radius |
|
| 99 | - * @since 0.5.0 |
|
| 100 | - */ |
|
| 101 | - const RADIUS = 'radius'; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @var string rankby |
|
| 105 | - * @since 0.5.0 |
|
| 106 | - */ |
|
| 107 | - const RANKBY = 'rankby'; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @var string keyword |
|
| 111 | - * @since 0.5.0 |
|
| 112 | - */ |
|
| 113 | - const KEYWORD = 'keyword'; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @var string minprice |
|
| 117 | - * @since 0.5.0 |
|
| 118 | - */ |
|
| 119 | - const MINPRICE = 'minprice'; |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @var string maxprice |
|
| 123 | - * @since 0.5.0 |
|
| 124 | - */ |
|
| 125 | - const MAXPRICE = 'maxprice'; |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @var string name |
|
| 129 | - * @since 0.5.0 |
|
| 130 | - */ |
|
| 131 | - const NAME = 'name'; |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @var string opennow |
|
| 135 | - * @since 0.5.0 |
|
| 136 | - */ |
|
| 137 | - const OPENNOW = 'opennow'; |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @var string pagetoken |
|
| 141 | - * @since 0.5.0 |
|
| 142 | - */ |
|
| 143 | - const PAGETOKEN = 'pagetoken'; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @var string type |
|
| 147 | - * @since 0.5.0 |
|
| 148 | - */ |
|
| 149 | - const TYPE = 'type'; |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @var string query |
|
| 153 | - * @since 0.5.0 |
|
| 154 | - */ |
|
| 155 | - const QUERY = 'query'; |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @var string next_page_token |
|
| 159 | - * @since 0.5.0 |
|
| 160 | - */ |
|
| 161 | - const NEXT_PAGE_TOKEN = 'next_page_token'; |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * @var string photoreference |
|
| 165 | - * @since 0.6.0 |
|
| 166 | - */ |
|
| 167 | - const PHOTOREFERENCE = 'photoreference'; |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @var string maxwidth |
|
| 171 | - * @since 0.6.0 |
|
| 172 | - */ |
|
| 173 | - const MAXWIDTH = 'maxwidth'; |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @var string maxheight |
|
| 177 | - * @since 0.6.0 |
|
| 178 | - */ |
|
| 179 | - const MAXHEIGHT = 'maxheight'; |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @var string timestamp |
|
| 183 | - * @since 0.7.0 |
|
| 184 | - */ |
|
| 185 | - const TIMESTAMP = 'timestamp'; |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @var string region |
|
| 189 | - * @since 0.8.0 |
|
| 190 | - */ |
|
| 191 | - const REGION = 'region'; |
|
| 21 | + /** |
|
| 22 | + * @var string key |
|
| 23 | + */ |
|
| 24 | + const KEY = 'key'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var string sensor |
|
| 28 | + */ |
|
| 29 | + const SENSOR = 'sensor'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var string latlng |
|
| 33 | + */ |
|
| 34 | + const LATLNG = 'latlng'; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string address |
|
| 38 | + */ |
|
| 39 | + const ADDRESS = 'address'; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var string place_id |
|
| 43 | + */ |
|
| 44 | + const PLACE_ID = 'place_id'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string location |
|
| 48 | + * @since 0.5.0 |
|
| 49 | + */ |
|
| 50 | + const LOCATION = 'location'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var string locations |
|
| 54 | + */ |
|
| 55 | + const LOCATIONS = 'locations'; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var string path |
|
| 59 | + */ |
|
| 60 | + const PATH = 'path'; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var string samples |
|
| 64 | + */ |
|
| 65 | + const SAMPLES = 'samples'; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var string input |
|
| 69 | + * @since 0.5.0 |
|
| 70 | + */ |
|
| 71 | + const INPUT = 'input'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @var string inputtype |
|
| 75 | + * @since 0.5.0 |
|
| 76 | + */ |
|
| 77 | + const INPUTTYPE = 'inputtype'; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @var string language |
|
| 81 | + * @since 0.5.0 |
|
| 82 | + */ |
|
| 83 | + const LANGUAGE = 'language'; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @var string fields |
|
| 87 | + * @since 0.5.0 |
|
| 88 | + */ |
|
| 89 | + const FIELDS = 'fields'; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @var string locationbias |
|
| 93 | + * @since 0.5.0 |
|
| 94 | + */ |
|
| 95 | + const LOCATIONBIAS = 'locationbias'; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @var string radius |
|
| 99 | + * @since 0.5.0 |
|
| 100 | + */ |
|
| 101 | + const RADIUS = 'radius'; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @var string rankby |
|
| 105 | + * @since 0.5.0 |
|
| 106 | + */ |
|
| 107 | + const RANKBY = 'rankby'; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @var string keyword |
|
| 111 | + * @since 0.5.0 |
|
| 112 | + */ |
|
| 113 | + const KEYWORD = 'keyword'; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @var string minprice |
|
| 117 | + * @since 0.5.0 |
|
| 118 | + */ |
|
| 119 | + const MINPRICE = 'minprice'; |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @var string maxprice |
|
| 123 | + * @since 0.5.0 |
|
| 124 | + */ |
|
| 125 | + const MAXPRICE = 'maxprice'; |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @var string name |
|
| 129 | + * @since 0.5.0 |
|
| 130 | + */ |
|
| 131 | + const NAME = 'name'; |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @var string opennow |
|
| 135 | + * @since 0.5.0 |
|
| 136 | + */ |
|
| 137 | + const OPENNOW = 'opennow'; |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @var string pagetoken |
|
| 141 | + * @since 0.5.0 |
|
| 142 | + */ |
|
| 143 | + const PAGETOKEN = 'pagetoken'; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @var string type |
|
| 147 | + * @since 0.5.0 |
|
| 148 | + */ |
|
| 149 | + const TYPE = 'type'; |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @var string query |
|
| 153 | + * @since 0.5.0 |
|
| 154 | + */ |
|
| 155 | + const QUERY = 'query'; |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @var string next_page_token |
|
| 159 | + * @since 0.5.0 |
|
| 160 | + */ |
|
| 161 | + const NEXT_PAGE_TOKEN = 'next_page_token'; |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * @var string photoreference |
|
| 165 | + * @since 0.6.0 |
|
| 166 | + */ |
|
| 167 | + const PHOTOREFERENCE = 'photoreference'; |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @var string maxwidth |
|
| 171 | + * @since 0.6.0 |
|
| 172 | + */ |
|
| 173 | + const MAXWIDTH = 'maxwidth'; |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @var string maxheight |
|
| 177 | + * @since 0.6.0 |
|
| 178 | + */ |
|
| 179 | + const MAXHEIGHT = 'maxheight'; |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @var string timestamp |
|
| 183 | + * @since 0.7.0 |
|
| 184 | + */ |
|
| 185 | + const TIMESTAMP = 'timestamp'; |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @var string region |
|
| 189 | + * @since 0.8.0 |
|
| 190 | + */ |
|
| 191 | + const REGION = 'region'; |
|
| 192 | 192 | } |