@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | * @author Jeroen Desloovere <[email protected]> |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -require_once __DIR__ . '/../src/Geolocation.php'; |
|
| 11 | +require_once __DIR__.'/../src/Geolocation.php'; |
|
| 12 | 12 | |
| 13 | 13 | use JeroenDesloovere\Geolocation\Geolocation; |
| 14 | 14 | |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | $result = Geolocation::getCoordinates('Koningin Maria Hendrikaplein', '1', 'Gent', '9000', 'belgië'); |
| 17 | 17 | |
| 18 | 18 | // dump result |
| 19 | -echo 'Coordinates = ' . $result['latitude'] . ', ' . $result['longitude'] . '<br/>'; |
|
| 19 | +echo 'Coordinates = '.$result['latitude'].', '.$result['longitude'].'<br/>'; |
|
| 20 | 20 | |
| 21 | 21 | // define result: @return array(label, street, streetNumber, city, cityLocal, zip, country, countryLabel) |
| 22 | 22 | $result = Geolocation::getAddress(51.0363935, 3.7121008); |
| 23 | 23 | |
| 24 | 24 | // define result |
| 25 | -echo 'Address = ' . $result['label'] . '<br/>'; |
|
| 25 | +echo 'Address = '.$result['label'].'<br/>'; |
|
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | namespace JeroenDesloovere\Geolocation\tests; |
| 4 | 4 | |
| 5 | 5 | // required to load |
| 6 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 6 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 7 | 7 | |
| 8 | 8 | /* |
| 9 | 9 | * This file is part of the Geolocation PHP Class from Jeroen Desloovere. |
@@ -42,16 +42,16 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | // define url |
| 45 | - $url = ($this->https ? 'https://' : 'http://') . self::API_URL . '?'; |
|
| 45 | + $url = ($this->https ? 'https://' : 'http://').self::API_URL.'?'; |
|
| 46 | 46 | |
| 47 | 47 | // add every parameter to the url |
| 48 | - foreach ($parameters as $key => $value) $url .= $key . '=' . urlencode($value) . '&'; |
|
| 48 | + foreach ($parameters as $key => $value) $url .= $key.'='.urlencode($value).'&'; |
|
| 49 | 49 | |
| 50 | 50 | // trim last & |
| 51 | 51 | $url = trim($url, '&'); |
| 52 | 52 | |
| 53 | 53 | if ($this->api_key) { |
| 54 | - $url .= '&key=' . $this->api_key; |
|
| 54 | + $url .= '&key='.$this->api_key; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // init curl |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | // define result |
| 113 | 113 | $addressSuggestions = $this->doCall(array( |
| 114 | - 'latlng' => $latitude . ',' . $longitude, |
|
| 114 | + 'latlng' => $latitude.','.$longitude, |
|
| 115 | 115 | 'sensor' => 'false' |
| 116 | 116 | )); |
| 117 | 117 | |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | $url = ($this->https ? 'https://' : 'http://') . self::API_URL . '?'; |
| 46 | 46 | |
| 47 | 47 | // add every parameter to the url |
| 48 | - foreach ($parameters as $key => $value) $url .= $key . '=' . urlencode($value) . '&'; |
|
| 48 | + foreach ($parameters as $key => $value) { |
|
| 49 | + $url .= $key . '=' . urlencode($value) . '&'; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // trim last & |
| 51 | 53 | $url = trim($url, '&'); |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | curl_setopt($curl, CURLOPT_URL, $url); |
| 62 | 64 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| 63 | 65 | curl_setopt($curl, CURLOPT_TIMEOUT, 10); |
| 64 | - if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
|
| 66 | + if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) { |
|
| 67 | + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // execute |
| 67 | 71 | $response = curl_exec($curl); |
@@ -74,7 +78,9 @@ discard block |
||
| 74 | 78 | curl_close($curl); |
| 75 | 79 | |
| 76 | 80 | // we have errors |
| 77 | - if ($errorNumber != '') throw new GeolocationException($errorMessage); |
|
| 81 | + if ($errorNumber != '') { |
|
| 82 | + throw new GeolocationException($errorMessage); |
|
| 83 | + } |
|
| 78 | 84 | |
| 79 | 85 | // redefine response as json decoded |
| 80 | 86 | $response = json_decode($response); |
@@ -161,19 +167,29 @@ discard block |
||
| 161 | 167 | $item = array(); |
| 162 | 168 | |
| 163 | 169 | // add street |
| 164 | - if (!empty($street)) $item[] = $street; |
|
| 170 | + if (!empty($street)) { |
|
| 171 | + $item[] = $street; |
|
| 172 | + } |
|
| 165 | 173 | |
| 166 | 174 | // add street number |
| 167 | - if (!empty($streetNumber)) $item[] = $streetNumber; |
|
| 175 | + if (!empty($streetNumber)) { |
|
| 176 | + $item[] = $streetNumber; |
|
| 177 | + } |
|
| 168 | 178 | |
| 169 | 179 | // add city |
| 170 | - if (!empty($city)) $item[] = $city; |
|
| 180 | + if (!empty($city)) { |
|
| 181 | + $item[] = $city; |
|
| 182 | + } |
|
| 171 | 183 | |
| 172 | 184 | // add zip |
| 173 | - if (!empty($zip)) $item[] = $zip; |
|
| 185 | + if (!empty($zip)) { |
|
| 186 | + $item[] = $zip; |
|
| 187 | + } |
|
| 174 | 188 | |
| 175 | 189 | // add country |
| 176 | - if (!empty($country)) $item[] = $country; |
|
| 190 | + if (!empty($country)) { |
|
| 191 | + $item[] = $country; |
|
| 192 | + } |
|
| 177 | 193 | |
| 178 | 194 | // define value |
| 179 | 195 | $address = implode(' ', $item); |