├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml.dist ├── src ├── Exception.php ├── Geolocation.php └── Result │ ├── Address.php │ └── Coordinates.php └── tests └── GeolocationTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 7.1 5 | - 7.2 6 | 7 | sudo: false 8 | 9 | script: 10 | - vendor/bin/phpcs --standard=psr2 --extensions=php --warning-severity=0 --report=full "src" 11 | - vendor/bin/phpunit --coverage-text 12 | 13 | before_script: 14 | - composer self-update 15 | - composer install --prefer-source --no-interaction --dev 16 | 17 | after_success: 18 | - wget https://scrutinizer-ci.com/ocular.phar 19 | - php ocular.phar code-coverage:upload --format=php-clover coverage.clover 20 | 21 | after_failure: 22 | - cat var/logs/test.log 23 | 24 | matrix: 25 | fast_finish: true 26 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 1.3.0 (2015-06-11) 2 | -- 3 | Improvements: 4 | * Core: removed static functions. 5 | 6 | 1.2.0 (2015-05-21) 7 | -- 8 | Improvements: 9 | * getAddress now returns array('label' => '', 'components' => array(array('long_name', 'short_name', 'types' => array()))); 10 | * New function getAddresses now added. 11 | * Tests added. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jeroen Desloovere 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Geolocation PHP class connects to Google MAPS API 2 | [![Latest Stable Version](http://img.shields.io/packagist/v/jeroendesloovere/geolocation-php-api.svg)](https://packagist.org/packages/jeroendesloovere/geolocation-php-api) 3 | [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg)](https://github.com/jeroendesloovere/geolocation-php-api/blob/master/LICENSE) 4 | [![Build Status](https://scrutinizer-ci.com/g/jeroendesloovere/geolocation-php-api/badges/build.png?b=master)](https://scrutinizer-ci.com/g/jeroendesloovere/geolocation-php-api/build-status/master) 5 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jeroendesloovere/geolocation-php-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jeroendesloovere/geolocation-php-api/?branch=master) 6 | 7 | > This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address. 8 | 9 | ## Installing 10 | 11 | ### Using Composer 12 | 13 | When using [Composer](https://getcomposer.org) you can always load in the latest version. 14 | 15 | ``` json 16 | composer require jeroendesloovere/geolocation-php-api 17 | ``` 18 | Check [in Packagist](https://packagist.org/packages/jeroendesloovere/geolocation-php-api). 19 | 20 | ### Usage example 21 | 22 | **getCoordinates** 23 | 24 | > Get latitude/longitude coordinates from address. 25 | 26 | ``` php 27 | $street = 'Koningin Maria Hendrikaplein'; 28 | $streetNumber = '1'; 29 | $city = 'Gent'; 30 | $zip = '1'; 31 | $country = 'belgium'; 32 | 33 | $result = Geolocation::getCoordinates( 34 | $street, 35 | $streetNumber, 36 | $city, 37 | $zip, 38 | $country 39 | ); 40 | ``` 41 | 42 | **getAddress** 43 | 44 | > Get address from latitude/longitude coordinates. 45 | 46 | ``` php 47 | $latitude = 51.0363935; 48 | $longitude = 3.7121008; 49 | 50 | $result = Geolocation::getAddress( 51 | $latitude, 52 | $longitude 53 | ); 54 | ``` 55 | 56 | Check [the Geolocation class source](./src/Geolocation.php). 57 | 58 | ## Symfony bundle 59 | 60 | I've also created a Symfony bundle. 61 | View the [Geolocation bundle](https://github.com/jeroendesloovere/geolocation-bundle). 62 | 63 | ## Tests 64 | 65 | We have tests to make sure everything works as expected. 66 | First execute `composer install`. 67 | Then execute `vendor/bin/phpunit tests`. 68 | 69 | ### Coding Syntax 70 | 71 | We use [squizlabs/php_codesniffer](https://packagist.org/packages/squizlabs/php_codesniffer) to maintain the code standards. 72 | Type the following to execute them: 73 | ```bash 74 | # To view the code errors 75 | vendor/bin/phpcs --standard=psr2 --extensions=php --warning-severity=0 --report=full "src" 76 | 77 | # OR to fix the code errors 78 | vendor/bin/phpcbf --standard=psr2 --extensions=php --warning-severity=0 --report=full "src" 79 | ``` 80 | > [Read documentation about the code standards](https://github.com/squizlabs/PHP_CodeSniffer/wiki) 81 | 82 | ## Documentation 83 | 84 | The class is well documented inline. If you use a decent IDE you'll see that each method is documented with PHPDoc. 85 | 86 | ## Contributing 87 | 88 | It would be great if you could help us improve this class. GitHub does a great job in managing collaboration by providing different tools, the only thing you need is a [GitHub](http://github.com) login. 89 | 90 | * Use **Pull requests** to add or update code 91 | * **Issues** for bug reporting or code discussions 92 | * Or regarding documentation and how-to's, check out **Wiki** 93 | More info on how to work with GitHub on help.github.com. 94 | 95 | ## License 96 | 97 | The module is licensed under [MIT](./LICENSE). In short, this license allows you to do everything as long as the copyright statement stays present. -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jeroendesloovere/geolocation-php-api", 3 | "type": "library", 4 | "description": "This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address.", 5 | "keywords": ["geolocation", "google", "maps", "api", "php"], 6 | "homepage": "https://github.com/jeroendesloovere/geolocation-php-api", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Jeroen Desloovere", 11 | "email": "info@jeroendesloovere.be", 12 | "homepage": "http://jeroendesloovere.be", 13 | "role": "Developer" 14 | } 15 | ], 16 | "require": { 17 | "php": ">=7.1" 18 | }, 19 | "require-dev": { 20 | "phpunit/phpunit": "^7.0", 21 | "squizlabs/php_codesniffer": "^3.2" 22 | }, 23 | "autoload": { 24 | "psr-4": { "JeroenDesloovere\\Geolocation\\": "src/" } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "719dadb52302cb78b93d0fbfb76b0abb", 8 | "packages": [], 9 | "packages-dev": [ 10 | { 11 | "name": "doctrine/instantiator", 12 | "version": "1.1.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/doctrine/instantiator.git", 16 | "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", 21 | "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "php": "^7.1" 26 | }, 27 | "require-dev": { 28 | "athletic/athletic": "~0.1.8", 29 | "ext-pdo": "*", 30 | "ext-phar": "*", 31 | "phpunit/phpunit": "^6.2.3", 32 | "squizlabs/php_codesniffer": "^3.0.2" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "1.2.x-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "psr-4": { 42 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 43 | } 44 | }, 45 | "notification-url": "https://packagist.org/downloads/", 46 | "license": [ 47 | "MIT" 48 | ], 49 | "authors": [ 50 | { 51 | "name": "Marco Pivetta", 52 | "email": "ocramius@gmail.com", 53 | "homepage": "http://ocramius.github.com/" 54 | } 55 | ], 56 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 57 | "homepage": "https://github.com/doctrine/instantiator", 58 | "keywords": [ 59 | "constructor", 60 | "instantiate" 61 | ], 62 | "time": "2017-07-22T11:58:36+00:00" 63 | }, 64 | { 65 | "name": "myclabs/deep-copy", 66 | "version": "1.7.0", 67 | "source": { 68 | "type": "git", 69 | "url": "https://github.com/myclabs/DeepCopy.git", 70 | "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" 71 | }, 72 | "dist": { 73 | "type": "zip", 74 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", 75 | "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", 76 | "shasum": "" 77 | }, 78 | "require": { 79 | "php": "^5.6 || ^7.0" 80 | }, 81 | "require-dev": { 82 | "doctrine/collections": "^1.0", 83 | "doctrine/common": "^2.6", 84 | "phpunit/phpunit": "^4.1" 85 | }, 86 | "type": "library", 87 | "autoload": { 88 | "psr-4": { 89 | "DeepCopy\\": "src/DeepCopy/" 90 | }, 91 | "files": [ 92 | "src/DeepCopy/deep_copy.php" 93 | ] 94 | }, 95 | "notification-url": "https://packagist.org/downloads/", 96 | "license": [ 97 | "MIT" 98 | ], 99 | "description": "Create deep copies (clones) of your objects", 100 | "keywords": [ 101 | "clone", 102 | "copy", 103 | "duplicate", 104 | "object", 105 | "object graph" 106 | ], 107 | "time": "2017-10-19T19:58:43+00:00" 108 | }, 109 | { 110 | "name": "phar-io/manifest", 111 | "version": "1.0.1", 112 | "source": { 113 | "type": "git", 114 | "url": "https://github.com/phar-io/manifest.git", 115 | "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" 116 | }, 117 | "dist": { 118 | "type": "zip", 119 | "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", 120 | "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", 121 | "shasum": "" 122 | }, 123 | "require": { 124 | "ext-dom": "*", 125 | "ext-phar": "*", 126 | "phar-io/version": "^1.0.1", 127 | "php": "^5.6 || ^7.0" 128 | }, 129 | "type": "library", 130 | "extra": { 131 | "branch-alias": { 132 | "dev-master": "1.0.x-dev" 133 | } 134 | }, 135 | "autoload": { 136 | "classmap": [ 137 | "src/" 138 | ] 139 | }, 140 | "notification-url": "https://packagist.org/downloads/", 141 | "license": [ 142 | "BSD-3-Clause" 143 | ], 144 | "authors": [ 145 | { 146 | "name": "Arne Blankerts", 147 | "email": "arne@blankerts.de", 148 | "role": "Developer" 149 | }, 150 | { 151 | "name": "Sebastian Heuer", 152 | "email": "sebastian@phpeople.de", 153 | "role": "Developer" 154 | }, 155 | { 156 | "name": "Sebastian Bergmann", 157 | "email": "sebastian@phpunit.de", 158 | "role": "Developer" 159 | } 160 | ], 161 | "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", 162 | "time": "2017-03-05T18:14:27+00:00" 163 | }, 164 | { 165 | "name": "phar-io/version", 166 | "version": "1.0.1", 167 | "source": { 168 | "type": "git", 169 | "url": "https://github.com/phar-io/version.git", 170 | "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" 171 | }, 172 | "dist": { 173 | "type": "zip", 174 | "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", 175 | "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", 176 | "shasum": "" 177 | }, 178 | "require": { 179 | "php": "^5.6 || ^7.0" 180 | }, 181 | "type": "library", 182 | "autoload": { 183 | "classmap": [ 184 | "src/" 185 | ] 186 | }, 187 | "notification-url": "https://packagist.org/downloads/", 188 | "license": [ 189 | "BSD-3-Clause" 190 | ], 191 | "authors": [ 192 | { 193 | "name": "Arne Blankerts", 194 | "email": "arne@blankerts.de", 195 | "role": "Developer" 196 | }, 197 | { 198 | "name": "Sebastian Heuer", 199 | "email": "sebastian@phpeople.de", 200 | "role": "Developer" 201 | }, 202 | { 203 | "name": "Sebastian Bergmann", 204 | "email": "sebastian@phpunit.de", 205 | "role": "Developer" 206 | } 207 | ], 208 | "description": "Library for handling version information and constraints", 209 | "time": "2017-03-05T17:38:23+00:00" 210 | }, 211 | { 212 | "name": "phpdocumentor/reflection-common", 213 | "version": "1.0.1", 214 | "source": { 215 | "type": "git", 216 | "url": "https://github.com/phpDocumentor/ReflectionCommon.git", 217 | "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" 218 | }, 219 | "dist": { 220 | "type": "zip", 221 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", 222 | "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", 223 | "shasum": "" 224 | }, 225 | "require": { 226 | "php": ">=5.5" 227 | }, 228 | "require-dev": { 229 | "phpunit/phpunit": "^4.6" 230 | }, 231 | "type": "library", 232 | "extra": { 233 | "branch-alias": { 234 | "dev-master": "1.0.x-dev" 235 | } 236 | }, 237 | "autoload": { 238 | "psr-4": { 239 | "phpDocumentor\\Reflection\\": [ 240 | "src" 241 | ] 242 | } 243 | }, 244 | "notification-url": "https://packagist.org/downloads/", 245 | "license": [ 246 | "MIT" 247 | ], 248 | "authors": [ 249 | { 250 | "name": "Jaap van Otterdijk", 251 | "email": "opensource@ijaap.nl" 252 | } 253 | ], 254 | "description": "Common reflection classes used by phpdocumentor to reflect the code structure", 255 | "homepage": "http://www.phpdoc.org", 256 | "keywords": [ 257 | "FQSEN", 258 | "phpDocumentor", 259 | "phpdoc", 260 | "reflection", 261 | "static analysis" 262 | ], 263 | "time": "2017-09-11T18:02:19+00:00" 264 | }, 265 | { 266 | "name": "phpdocumentor/reflection-docblock", 267 | "version": "4.3.0", 268 | "source": { 269 | "type": "git", 270 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 271 | "reference": "94fd0001232e47129dd3504189fa1c7225010d08" 272 | }, 273 | "dist": { 274 | "type": "zip", 275 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", 276 | "reference": "94fd0001232e47129dd3504189fa1c7225010d08", 277 | "shasum": "" 278 | }, 279 | "require": { 280 | "php": "^7.0", 281 | "phpdocumentor/reflection-common": "^1.0.0", 282 | "phpdocumentor/type-resolver": "^0.4.0", 283 | "webmozart/assert": "^1.0" 284 | }, 285 | "require-dev": { 286 | "doctrine/instantiator": "~1.0.5", 287 | "mockery/mockery": "^1.0", 288 | "phpunit/phpunit": "^6.4" 289 | }, 290 | "type": "library", 291 | "extra": { 292 | "branch-alias": { 293 | "dev-master": "4.x-dev" 294 | } 295 | }, 296 | "autoload": { 297 | "psr-4": { 298 | "phpDocumentor\\Reflection\\": [ 299 | "src/" 300 | ] 301 | } 302 | }, 303 | "notification-url": "https://packagist.org/downloads/", 304 | "license": [ 305 | "MIT" 306 | ], 307 | "authors": [ 308 | { 309 | "name": "Mike van Riel", 310 | "email": "me@mikevanriel.com" 311 | } 312 | ], 313 | "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", 314 | "time": "2017-11-30T07:14:17+00:00" 315 | }, 316 | { 317 | "name": "phpdocumentor/type-resolver", 318 | "version": "0.4.0", 319 | "source": { 320 | "type": "git", 321 | "url": "https://github.com/phpDocumentor/TypeResolver.git", 322 | "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" 323 | }, 324 | "dist": { 325 | "type": "zip", 326 | "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", 327 | "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", 328 | "shasum": "" 329 | }, 330 | "require": { 331 | "php": "^5.5 || ^7.0", 332 | "phpdocumentor/reflection-common": "^1.0" 333 | }, 334 | "require-dev": { 335 | "mockery/mockery": "^0.9.4", 336 | "phpunit/phpunit": "^5.2||^4.8.24" 337 | }, 338 | "type": "library", 339 | "extra": { 340 | "branch-alias": { 341 | "dev-master": "1.0.x-dev" 342 | } 343 | }, 344 | "autoload": { 345 | "psr-4": { 346 | "phpDocumentor\\Reflection\\": [ 347 | "src/" 348 | ] 349 | } 350 | }, 351 | "notification-url": "https://packagist.org/downloads/", 352 | "license": [ 353 | "MIT" 354 | ], 355 | "authors": [ 356 | { 357 | "name": "Mike van Riel", 358 | "email": "me@mikevanriel.com" 359 | } 360 | ], 361 | "time": "2017-07-14T14:27:02+00:00" 362 | }, 363 | { 364 | "name": "phpspec/prophecy", 365 | "version": "1.7.5", 366 | "source": { 367 | "type": "git", 368 | "url": "https://github.com/phpspec/prophecy.git", 369 | "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" 370 | }, 371 | "dist": { 372 | "type": "zip", 373 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", 374 | "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", 375 | "shasum": "" 376 | }, 377 | "require": { 378 | "doctrine/instantiator": "^1.0.2", 379 | "php": "^5.3|^7.0", 380 | "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", 381 | "sebastian/comparator": "^1.1|^2.0", 382 | "sebastian/recursion-context": "^1.0|^2.0|^3.0" 383 | }, 384 | "require-dev": { 385 | "phpspec/phpspec": "^2.5|^3.2", 386 | "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" 387 | }, 388 | "type": "library", 389 | "extra": { 390 | "branch-alias": { 391 | "dev-master": "1.7.x-dev" 392 | } 393 | }, 394 | "autoload": { 395 | "psr-0": { 396 | "Prophecy\\": "src/" 397 | } 398 | }, 399 | "notification-url": "https://packagist.org/downloads/", 400 | "license": [ 401 | "MIT" 402 | ], 403 | "authors": [ 404 | { 405 | "name": "Konstantin Kudryashov", 406 | "email": "ever.zet@gmail.com", 407 | "homepage": "http://everzet.com" 408 | }, 409 | { 410 | "name": "Marcello Duarte", 411 | "email": "marcello.duarte@gmail.com" 412 | } 413 | ], 414 | "description": "Highly opinionated mocking framework for PHP 5.3+", 415 | "homepage": "https://github.com/phpspec/prophecy", 416 | "keywords": [ 417 | "Double", 418 | "Dummy", 419 | "fake", 420 | "mock", 421 | "spy", 422 | "stub" 423 | ], 424 | "time": "2018-02-19T10:16:54+00:00" 425 | }, 426 | { 427 | "name": "phpunit/php-code-coverage", 428 | "version": "6.0.1", 429 | "source": { 430 | "type": "git", 431 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 432 | "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba" 433 | }, 434 | "dist": { 435 | "type": "zip", 436 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f8ca4b604baf23dab89d87773c28cc07405189ba", 437 | "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba", 438 | "shasum": "" 439 | }, 440 | "require": { 441 | "ext-dom": "*", 442 | "ext-xmlwriter": "*", 443 | "php": "^7.1", 444 | "phpunit/php-file-iterator": "^1.4.2", 445 | "phpunit/php-text-template": "^1.2.1", 446 | "phpunit/php-token-stream": "^3.0", 447 | "sebastian/code-unit-reverse-lookup": "^1.0.1", 448 | "sebastian/environment": "^3.0", 449 | "sebastian/version": "^2.0.1", 450 | "theseer/tokenizer": "^1.1" 451 | }, 452 | "require-dev": { 453 | "phpunit/phpunit": "^7.0" 454 | }, 455 | "suggest": { 456 | "ext-xdebug": "^2.6.0" 457 | }, 458 | "type": "library", 459 | "extra": { 460 | "branch-alias": { 461 | "dev-master": "6.0-dev" 462 | } 463 | }, 464 | "autoload": { 465 | "classmap": [ 466 | "src/" 467 | ] 468 | }, 469 | "notification-url": "https://packagist.org/downloads/", 470 | "license": [ 471 | "BSD-3-Clause" 472 | ], 473 | "authors": [ 474 | { 475 | "name": "Sebastian Bergmann", 476 | "email": "sebastian@phpunit.de", 477 | "role": "lead" 478 | } 479 | ], 480 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 481 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 482 | "keywords": [ 483 | "coverage", 484 | "testing", 485 | "xunit" 486 | ], 487 | "time": "2018-02-02T07:01:41+00:00" 488 | }, 489 | { 490 | "name": "phpunit/php-file-iterator", 491 | "version": "1.4.5", 492 | "source": { 493 | "type": "git", 494 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 495 | "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" 496 | }, 497 | "dist": { 498 | "type": "zip", 499 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", 500 | "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", 501 | "shasum": "" 502 | }, 503 | "require": { 504 | "php": ">=5.3.3" 505 | }, 506 | "type": "library", 507 | "extra": { 508 | "branch-alias": { 509 | "dev-master": "1.4.x-dev" 510 | } 511 | }, 512 | "autoload": { 513 | "classmap": [ 514 | "src/" 515 | ] 516 | }, 517 | "notification-url": "https://packagist.org/downloads/", 518 | "license": [ 519 | "BSD-3-Clause" 520 | ], 521 | "authors": [ 522 | { 523 | "name": "Sebastian Bergmann", 524 | "email": "sb@sebastian-bergmann.de", 525 | "role": "lead" 526 | } 527 | ], 528 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 529 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 530 | "keywords": [ 531 | "filesystem", 532 | "iterator" 533 | ], 534 | "time": "2017-11-27T13:52:08+00:00" 535 | }, 536 | { 537 | "name": "phpunit/php-text-template", 538 | "version": "1.2.1", 539 | "source": { 540 | "type": "git", 541 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 542 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 543 | }, 544 | "dist": { 545 | "type": "zip", 546 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 547 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 548 | "shasum": "" 549 | }, 550 | "require": { 551 | "php": ">=5.3.3" 552 | }, 553 | "type": "library", 554 | "autoload": { 555 | "classmap": [ 556 | "src/" 557 | ] 558 | }, 559 | "notification-url": "https://packagist.org/downloads/", 560 | "license": [ 561 | "BSD-3-Clause" 562 | ], 563 | "authors": [ 564 | { 565 | "name": "Sebastian Bergmann", 566 | "email": "sebastian@phpunit.de", 567 | "role": "lead" 568 | } 569 | ], 570 | "description": "Simple template engine.", 571 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 572 | "keywords": [ 573 | "template" 574 | ], 575 | "time": "2015-06-21T13:50:34+00:00" 576 | }, 577 | { 578 | "name": "phpunit/php-timer", 579 | "version": "2.0.0", 580 | "source": { 581 | "type": "git", 582 | "url": "https://github.com/sebastianbergmann/php-timer.git", 583 | "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" 584 | }, 585 | "dist": { 586 | "type": "zip", 587 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", 588 | "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", 589 | "shasum": "" 590 | }, 591 | "require": { 592 | "php": "^7.1" 593 | }, 594 | "require-dev": { 595 | "phpunit/phpunit": "^7.0" 596 | }, 597 | "type": "library", 598 | "extra": { 599 | "branch-alias": { 600 | "dev-master": "2.0-dev" 601 | } 602 | }, 603 | "autoload": { 604 | "classmap": [ 605 | "src/" 606 | ] 607 | }, 608 | "notification-url": "https://packagist.org/downloads/", 609 | "license": [ 610 | "BSD-3-Clause" 611 | ], 612 | "authors": [ 613 | { 614 | "name": "Sebastian Bergmann", 615 | "email": "sebastian@phpunit.de", 616 | "role": "lead" 617 | } 618 | ], 619 | "description": "Utility class for timing", 620 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 621 | "keywords": [ 622 | "timer" 623 | ], 624 | "time": "2018-02-01T13:07:23+00:00" 625 | }, 626 | { 627 | "name": "phpunit/php-token-stream", 628 | "version": "3.0.0", 629 | "source": { 630 | "type": "git", 631 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 632 | "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" 633 | }, 634 | "dist": { 635 | "type": "zip", 636 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", 637 | "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", 638 | "shasum": "" 639 | }, 640 | "require": { 641 | "ext-tokenizer": "*", 642 | "php": "^7.1" 643 | }, 644 | "require-dev": { 645 | "phpunit/phpunit": "^7.0" 646 | }, 647 | "type": "library", 648 | "extra": { 649 | "branch-alias": { 650 | "dev-master": "3.0-dev" 651 | } 652 | }, 653 | "autoload": { 654 | "classmap": [ 655 | "src/" 656 | ] 657 | }, 658 | "notification-url": "https://packagist.org/downloads/", 659 | "license": [ 660 | "BSD-3-Clause" 661 | ], 662 | "authors": [ 663 | { 664 | "name": "Sebastian Bergmann", 665 | "email": "sebastian@phpunit.de" 666 | } 667 | ], 668 | "description": "Wrapper around PHP's tokenizer extension.", 669 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 670 | "keywords": [ 671 | "tokenizer" 672 | ], 673 | "time": "2018-02-01T13:16:43+00:00" 674 | }, 675 | { 676 | "name": "phpunit/phpunit", 677 | "version": "7.0.3", 678 | "source": { 679 | "type": "git", 680 | "url": "https://github.com/sebastianbergmann/phpunit.git", 681 | "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e" 682 | }, 683 | "dist": { 684 | "type": "zip", 685 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/536f4d853c12d8189963435088e8ff7c0daeab2e", 686 | "reference": "536f4d853c12d8189963435088e8ff7c0daeab2e", 687 | "shasum": "" 688 | }, 689 | "require": { 690 | "ext-dom": "*", 691 | "ext-json": "*", 692 | "ext-libxml": "*", 693 | "ext-mbstring": "*", 694 | "ext-xml": "*", 695 | "myclabs/deep-copy": "^1.6.1", 696 | "phar-io/manifest": "^1.0.1", 697 | "phar-io/version": "^1.0", 698 | "php": "^7.1", 699 | "phpspec/prophecy": "^1.7", 700 | "phpunit/php-code-coverage": "^6.0.1", 701 | "phpunit/php-file-iterator": "^1.4.3", 702 | "phpunit/php-text-template": "^1.2.1", 703 | "phpunit/php-timer": "^2.0", 704 | "phpunit/phpunit-mock-objects": "^6.0", 705 | "sebastian/comparator": "^2.1", 706 | "sebastian/diff": "^3.0", 707 | "sebastian/environment": "^3.1", 708 | "sebastian/exporter": "^3.1", 709 | "sebastian/global-state": "^2.0", 710 | "sebastian/object-enumerator": "^3.0.3", 711 | "sebastian/resource-operations": "^1.0", 712 | "sebastian/version": "^2.0.1" 713 | }, 714 | "require-dev": { 715 | "ext-pdo": "*" 716 | }, 717 | "suggest": { 718 | "ext-xdebug": "*", 719 | "phpunit/php-invoker": "^2.0" 720 | }, 721 | "bin": [ 722 | "phpunit" 723 | ], 724 | "type": "library", 725 | "extra": { 726 | "branch-alias": { 727 | "dev-master": "7.0-dev" 728 | } 729 | }, 730 | "autoload": { 731 | "classmap": [ 732 | "src/" 733 | ] 734 | }, 735 | "notification-url": "https://packagist.org/downloads/", 736 | "license": [ 737 | "BSD-3-Clause" 738 | ], 739 | "authors": [ 740 | { 741 | "name": "Sebastian Bergmann", 742 | "email": "sebastian@phpunit.de", 743 | "role": "lead" 744 | } 745 | ], 746 | "description": "The PHP Unit Testing framework.", 747 | "homepage": "https://phpunit.de/", 748 | "keywords": [ 749 | "phpunit", 750 | "testing", 751 | "xunit" 752 | ], 753 | "time": "2018-03-26T07:36:48+00:00" 754 | }, 755 | { 756 | "name": "phpunit/phpunit-mock-objects", 757 | "version": "6.0.1", 758 | "source": { 759 | "type": "git", 760 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 761 | "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53" 762 | }, 763 | "dist": { 764 | "type": "zip", 765 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/e3249dedc2d99259ccae6affbc2684eac37c2e53", 766 | "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53", 767 | "shasum": "" 768 | }, 769 | "require": { 770 | "doctrine/instantiator": "^1.0.5", 771 | "php": "^7.1", 772 | "phpunit/php-text-template": "^1.2.1", 773 | "sebastian/exporter": "^3.1" 774 | }, 775 | "require-dev": { 776 | "phpunit/phpunit": "^7.0" 777 | }, 778 | "suggest": { 779 | "ext-soap": "*" 780 | }, 781 | "type": "library", 782 | "extra": { 783 | "branch-alias": { 784 | "dev-master": "6.0.x-dev" 785 | } 786 | }, 787 | "autoload": { 788 | "classmap": [ 789 | "src/" 790 | ] 791 | }, 792 | "notification-url": "https://packagist.org/downloads/", 793 | "license": [ 794 | "BSD-3-Clause" 795 | ], 796 | "authors": [ 797 | { 798 | "name": "Sebastian Bergmann", 799 | "email": "sebastian@phpunit.de", 800 | "role": "lead" 801 | } 802 | ], 803 | "description": "Mock Object library for PHPUnit", 804 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 805 | "keywords": [ 806 | "mock", 807 | "xunit" 808 | ], 809 | "time": "2018-02-15T05:27:38+00:00" 810 | }, 811 | { 812 | "name": "sebastian/code-unit-reverse-lookup", 813 | "version": "1.0.1", 814 | "source": { 815 | "type": "git", 816 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 817 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" 818 | }, 819 | "dist": { 820 | "type": "zip", 821 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 822 | "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", 823 | "shasum": "" 824 | }, 825 | "require": { 826 | "php": "^5.6 || ^7.0" 827 | }, 828 | "require-dev": { 829 | "phpunit/phpunit": "^5.7 || ^6.0" 830 | }, 831 | "type": "library", 832 | "extra": { 833 | "branch-alias": { 834 | "dev-master": "1.0.x-dev" 835 | } 836 | }, 837 | "autoload": { 838 | "classmap": [ 839 | "src/" 840 | ] 841 | }, 842 | "notification-url": "https://packagist.org/downloads/", 843 | "license": [ 844 | "BSD-3-Clause" 845 | ], 846 | "authors": [ 847 | { 848 | "name": "Sebastian Bergmann", 849 | "email": "sebastian@phpunit.de" 850 | } 851 | ], 852 | "description": "Looks up which function or method a line of code belongs to", 853 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 854 | "time": "2017-03-04T06:30:41+00:00" 855 | }, 856 | { 857 | "name": "sebastian/comparator", 858 | "version": "2.1.3", 859 | "source": { 860 | "type": "git", 861 | "url": "https://github.com/sebastianbergmann/comparator.git", 862 | "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" 863 | }, 864 | "dist": { 865 | "type": "zip", 866 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", 867 | "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", 868 | "shasum": "" 869 | }, 870 | "require": { 871 | "php": "^7.0", 872 | "sebastian/diff": "^2.0 || ^3.0", 873 | "sebastian/exporter": "^3.1" 874 | }, 875 | "require-dev": { 876 | "phpunit/phpunit": "^6.4" 877 | }, 878 | "type": "library", 879 | "extra": { 880 | "branch-alias": { 881 | "dev-master": "2.1.x-dev" 882 | } 883 | }, 884 | "autoload": { 885 | "classmap": [ 886 | "src/" 887 | ] 888 | }, 889 | "notification-url": "https://packagist.org/downloads/", 890 | "license": [ 891 | "BSD-3-Clause" 892 | ], 893 | "authors": [ 894 | { 895 | "name": "Jeff Welch", 896 | "email": "whatthejeff@gmail.com" 897 | }, 898 | { 899 | "name": "Volker Dusch", 900 | "email": "github@wallbash.com" 901 | }, 902 | { 903 | "name": "Bernhard Schussek", 904 | "email": "bschussek@2bepublished.at" 905 | }, 906 | { 907 | "name": "Sebastian Bergmann", 908 | "email": "sebastian@phpunit.de" 909 | } 910 | ], 911 | "description": "Provides the functionality to compare PHP values for equality", 912 | "homepage": "https://github.com/sebastianbergmann/comparator", 913 | "keywords": [ 914 | "comparator", 915 | "compare", 916 | "equality" 917 | ], 918 | "time": "2018-02-01T13:46:46+00:00" 919 | }, 920 | { 921 | "name": "sebastian/diff", 922 | "version": "3.0.0", 923 | "source": { 924 | "type": "git", 925 | "url": "https://github.com/sebastianbergmann/diff.git", 926 | "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8" 927 | }, 928 | "dist": { 929 | "type": "zip", 930 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e09160918c66281713f1c324c1f4c4c3037ba1e8", 931 | "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8", 932 | "shasum": "" 933 | }, 934 | "require": { 935 | "php": "^7.1" 936 | }, 937 | "require-dev": { 938 | "phpunit/phpunit": "^7.0", 939 | "symfony/process": "^2 || ^3.3 || ^4" 940 | }, 941 | "type": "library", 942 | "extra": { 943 | "branch-alias": { 944 | "dev-master": "3.0-dev" 945 | } 946 | }, 947 | "autoload": { 948 | "classmap": [ 949 | "src/" 950 | ] 951 | }, 952 | "notification-url": "https://packagist.org/downloads/", 953 | "license": [ 954 | "BSD-3-Clause" 955 | ], 956 | "authors": [ 957 | { 958 | "name": "Kore Nordmann", 959 | "email": "mail@kore-nordmann.de" 960 | }, 961 | { 962 | "name": "Sebastian Bergmann", 963 | "email": "sebastian@phpunit.de" 964 | } 965 | ], 966 | "description": "Diff implementation", 967 | "homepage": "https://github.com/sebastianbergmann/diff", 968 | "keywords": [ 969 | "diff", 970 | "udiff", 971 | "unidiff", 972 | "unified diff" 973 | ], 974 | "time": "2018-02-01T13:45:15+00:00" 975 | }, 976 | { 977 | "name": "sebastian/environment", 978 | "version": "3.1.0", 979 | "source": { 980 | "type": "git", 981 | "url": "https://github.com/sebastianbergmann/environment.git", 982 | "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" 983 | }, 984 | "dist": { 985 | "type": "zip", 986 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", 987 | "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", 988 | "shasum": "" 989 | }, 990 | "require": { 991 | "php": "^7.0" 992 | }, 993 | "require-dev": { 994 | "phpunit/phpunit": "^6.1" 995 | }, 996 | "type": "library", 997 | "extra": { 998 | "branch-alias": { 999 | "dev-master": "3.1.x-dev" 1000 | } 1001 | }, 1002 | "autoload": { 1003 | "classmap": [ 1004 | "src/" 1005 | ] 1006 | }, 1007 | "notification-url": "https://packagist.org/downloads/", 1008 | "license": [ 1009 | "BSD-3-Clause" 1010 | ], 1011 | "authors": [ 1012 | { 1013 | "name": "Sebastian Bergmann", 1014 | "email": "sebastian@phpunit.de" 1015 | } 1016 | ], 1017 | "description": "Provides functionality to handle HHVM/PHP environments", 1018 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1019 | "keywords": [ 1020 | "Xdebug", 1021 | "environment", 1022 | "hhvm" 1023 | ], 1024 | "time": "2017-07-01T08:51:00+00:00" 1025 | }, 1026 | { 1027 | "name": "sebastian/exporter", 1028 | "version": "3.1.0", 1029 | "source": { 1030 | "type": "git", 1031 | "url": "https://github.com/sebastianbergmann/exporter.git", 1032 | "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" 1033 | }, 1034 | "dist": { 1035 | "type": "zip", 1036 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", 1037 | "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", 1038 | "shasum": "" 1039 | }, 1040 | "require": { 1041 | "php": "^7.0", 1042 | "sebastian/recursion-context": "^3.0" 1043 | }, 1044 | "require-dev": { 1045 | "ext-mbstring": "*", 1046 | "phpunit/phpunit": "^6.0" 1047 | }, 1048 | "type": "library", 1049 | "extra": { 1050 | "branch-alias": { 1051 | "dev-master": "3.1.x-dev" 1052 | } 1053 | }, 1054 | "autoload": { 1055 | "classmap": [ 1056 | "src/" 1057 | ] 1058 | }, 1059 | "notification-url": "https://packagist.org/downloads/", 1060 | "license": [ 1061 | "BSD-3-Clause" 1062 | ], 1063 | "authors": [ 1064 | { 1065 | "name": "Jeff Welch", 1066 | "email": "whatthejeff@gmail.com" 1067 | }, 1068 | { 1069 | "name": "Volker Dusch", 1070 | "email": "github@wallbash.com" 1071 | }, 1072 | { 1073 | "name": "Bernhard Schussek", 1074 | "email": "bschussek@2bepublished.at" 1075 | }, 1076 | { 1077 | "name": "Sebastian Bergmann", 1078 | "email": "sebastian@phpunit.de" 1079 | }, 1080 | { 1081 | "name": "Adam Harvey", 1082 | "email": "aharvey@php.net" 1083 | } 1084 | ], 1085 | "description": "Provides the functionality to export PHP variables for visualization", 1086 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1087 | "keywords": [ 1088 | "export", 1089 | "exporter" 1090 | ], 1091 | "time": "2017-04-03T13:19:02+00:00" 1092 | }, 1093 | { 1094 | "name": "sebastian/global-state", 1095 | "version": "2.0.0", 1096 | "source": { 1097 | "type": "git", 1098 | "url": "https://github.com/sebastianbergmann/global-state.git", 1099 | "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" 1100 | }, 1101 | "dist": { 1102 | "type": "zip", 1103 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", 1104 | "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", 1105 | "shasum": "" 1106 | }, 1107 | "require": { 1108 | "php": "^7.0" 1109 | }, 1110 | "require-dev": { 1111 | "phpunit/phpunit": "^6.0" 1112 | }, 1113 | "suggest": { 1114 | "ext-uopz": "*" 1115 | }, 1116 | "type": "library", 1117 | "extra": { 1118 | "branch-alias": { 1119 | "dev-master": "2.0-dev" 1120 | } 1121 | }, 1122 | "autoload": { 1123 | "classmap": [ 1124 | "src/" 1125 | ] 1126 | }, 1127 | "notification-url": "https://packagist.org/downloads/", 1128 | "license": [ 1129 | "BSD-3-Clause" 1130 | ], 1131 | "authors": [ 1132 | { 1133 | "name": "Sebastian Bergmann", 1134 | "email": "sebastian@phpunit.de" 1135 | } 1136 | ], 1137 | "description": "Snapshotting of global state", 1138 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1139 | "keywords": [ 1140 | "global state" 1141 | ], 1142 | "time": "2017-04-27T15:39:26+00:00" 1143 | }, 1144 | { 1145 | "name": "sebastian/object-enumerator", 1146 | "version": "3.0.3", 1147 | "source": { 1148 | "type": "git", 1149 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1150 | "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" 1151 | }, 1152 | "dist": { 1153 | "type": "zip", 1154 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", 1155 | "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", 1156 | "shasum": "" 1157 | }, 1158 | "require": { 1159 | "php": "^7.0", 1160 | "sebastian/object-reflector": "^1.1.1", 1161 | "sebastian/recursion-context": "^3.0" 1162 | }, 1163 | "require-dev": { 1164 | "phpunit/phpunit": "^6.0" 1165 | }, 1166 | "type": "library", 1167 | "extra": { 1168 | "branch-alias": { 1169 | "dev-master": "3.0.x-dev" 1170 | } 1171 | }, 1172 | "autoload": { 1173 | "classmap": [ 1174 | "src/" 1175 | ] 1176 | }, 1177 | "notification-url": "https://packagist.org/downloads/", 1178 | "license": [ 1179 | "BSD-3-Clause" 1180 | ], 1181 | "authors": [ 1182 | { 1183 | "name": "Sebastian Bergmann", 1184 | "email": "sebastian@phpunit.de" 1185 | } 1186 | ], 1187 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1188 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1189 | "time": "2017-08-03T12:35:26+00:00" 1190 | }, 1191 | { 1192 | "name": "sebastian/object-reflector", 1193 | "version": "1.1.1", 1194 | "source": { 1195 | "type": "git", 1196 | "url": "https://github.com/sebastianbergmann/object-reflector.git", 1197 | "reference": "773f97c67f28de00d397be301821b06708fca0be" 1198 | }, 1199 | "dist": { 1200 | "type": "zip", 1201 | "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", 1202 | "reference": "773f97c67f28de00d397be301821b06708fca0be", 1203 | "shasum": "" 1204 | }, 1205 | "require": { 1206 | "php": "^7.0" 1207 | }, 1208 | "require-dev": { 1209 | "phpunit/phpunit": "^6.0" 1210 | }, 1211 | "type": "library", 1212 | "extra": { 1213 | "branch-alias": { 1214 | "dev-master": "1.1-dev" 1215 | } 1216 | }, 1217 | "autoload": { 1218 | "classmap": [ 1219 | "src/" 1220 | ] 1221 | }, 1222 | "notification-url": "https://packagist.org/downloads/", 1223 | "license": [ 1224 | "BSD-3-Clause" 1225 | ], 1226 | "authors": [ 1227 | { 1228 | "name": "Sebastian Bergmann", 1229 | "email": "sebastian@phpunit.de" 1230 | } 1231 | ], 1232 | "description": "Allows reflection of object attributes, including inherited and non-public ones", 1233 | "homepage": "https://github.com/sebastianbergmann/object-reflector/", 1234 | "time": "2017-03-29T09:07:27+00:00" 1235 | }, 1236 | { 1237 | "name": "sebastian/recursion-context", 1238 | "version": "3.0.0", 1239 | "source": { 1240 | "type": "git", 1241 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1242 | "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" 1243 | }, 1244 | "dist": { 1245 | "type": "zip", 1246 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", 1247 | "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", 1248 | "shasum": "" 1249 | }, 1250 | "require": { 1251 | "php": "^7.0" 1252 | }, 1253 | "require-dev": { 1254 | "phpunit/phpunit": "^6.0" 1255 | }, 1256 | "type": "library", 1257 | "extra": { 1258 | "branch-alias": { 1259 | "dev-master": "3.0.x-dev" 1260 | } 1261 | }, 1262 | "autoload": { 1263 | "classmap": [ 1264 | "src/" 1265 | ] 1266 | }, 1267 | "notification-url": "https://packagist.org/downloads/", 1268 | "license": [ 1269 | "BSD-3-Clause" 1270 | ], 1271 | "authors": [ 1272 | { 1273 | "name": "Jeff Welch", 1274 | "email": "whatthejeff@gmail.com" 1275 | }, 1276 | { 1277 | "name": "Sebastian Bergmann", 1278 | "email": "sebastian@phpunit.de" 1279 | }, 1280 | { 1281 | "name": "Adam Harvey", 1282 | "email": "aharvey@php.net" 1283 | } 1284 | ], 1285 | "description": "Provides functionality to recursively process PHP variables", 1286 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1287 | "time": "2017-03-03T06:23:57+00:00" 1288 | }, 1289 | { 1290 | "name": "sebastian/resource-operations", 1291 | "version": "1.0.0", 1292 | "source": { 1293 | "type": "git", 1294 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1295 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" 1296 | }, 1297 | "dist": { 1298 | "type": "zip", 1299 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1300 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1301 | "shasum": "" 1302 | }, 1303 | "require": { 1304 | "php": ">=5.6.0" 1305 | }, 1306 | "type": "library", 1307 | "extra": { 1308 | "branch-alias": { 1309 | "dev-master": "1.0.x-dev" 1310 | } 1311 | }, 1312 | "autoload": { 1313 | "classmap": [ 1314 | "src/" 1315 | ] 1316 | }, 1317 | "notification-url": "https://packagist.org/downloads/", 1318 | "license": [ 1319 | "BSD-3-Clause" 1320 | ], 1321 | "authors": [ 1322 | { 1323 | "name": "Sebastian Bergmann", 1324 | "email": "sebastian@phpunit.de" 1325 | } 1326 | ], 1327 | "description": "Provides a list of PHP built-in functions that operate on resources", 1328 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1329 | "time": "2015-07-28T20:34:47+00:00" 1330 | }, 1331 | { 1332 | "name": "sebastian/version", 1333 | "version": "2.0.1", 1334 | "source": { 1335 | "type": "git", 1336 | "url": "https://github.com/sebastianbergmann/version.git", 1337 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" 1338 | }, 1339 | "dist": { 1340 | "type": "zip", 1341 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", 1342 | "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", 1343 | "shasum": "" 1344 | }, 1345 | "require": { 1346 | "php": ">=5.6" 1347 | }, 1348 | "type": "library", 1349 | "extra": { 1350 | "branch-alias": { 1351 | "dev-master": "2.0.x-dev" 1352 | } 1353 | }, 1354 | "autoload": { 1355 | "classmap": [ 1356 | "src/" 1357 | ] 1358 | }, 1359 | "notification-url": "https://packagist.org/downloads/", 1360 | "license": [ 1361 | "BSD-3-Clause" 1362 | ], 1363 | "authors": [ 1364 | { 1365 | "name": "Sebastian Bergmann", 1366 | "email": "sebastian@phpunit.de", 1367 | "role": "lead" 1368 | } 1369 | ], 1370 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1371 | "homepage": "https://github.com/sebastianbergmann/version", 1372 | "time": "2016-10-03T07:35:21+00:00" 1373 | }, 1374 | { 1375 | "name": "squizlabs/php_codesniffer", 1376 | "version": "3.2.3", 1377 | "source": { 1378 | "type": "git", 1379 | "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", 1380 | "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" 1381 | }, 1382 | "dist": { 1383 | "type": "zip", 1384 | "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", 1385 | "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", 1386 | "shasum": "" 1387 | }, 1388 | "require": { 1389 | "ext-simplexml": "*", 1390 | "ext-tokenizer": "*", 1391 | "ext-xmlwriter": "*", 1392 | "php": ">=5.4.0" 1393 | }, 1394 | "require-dev": { 1395 | "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" 1396 | }, 1397 | "bin": [ 1398 | "bin/phpcs", 1399 | "bin/phpcbf" 1400 | ], 1401 | "type": "library", 1402 | "extra": { 1403 | "branch-alias": { 1404 | "dev-master": "3.x-dev" 1405 | } 1406 | }, 1407 | "notification-url": "https://packagist.org/downloads/", 1408 | "license": [ 1409 | "BSD-3-Clause" 1410 | ], 1411 | "authors": [ 1412 | { 1413 | "name": "Greg Sherwood", 1414 | "role": "lead" 1415 | } 1416 | ], 1417 | "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", 1418 | "homepage": "http://www.squizlabs.com/php-codesniffer", 1419 | "keywords": [ 1420 | "phpcs", 1421 | "standards" 1422 | ], 1423 | "time": "2018-02-20T21:35:23+00:00" 1424 | }, 1425 | { 1426 | "name": "theseer/tokenizer", 1427 | "version": "1.1.0", 1428 | "source": { 1429 | "type": "git", 1430 | "url": "https://github.com/theseer/tokenizer.git", 1431 | "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" 1432 | }, 1433 | "dist": { 1434 | "type": "zip", 1435 | "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", 1436 | "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", 1437 | "shasum": "" 1438 | }, 1439 | "require": { 1440 | "ext-dom": "*", 1441 | "ext-tokenizer": "*", 1442 | "ext-xmlwriter": "*", 1443 | "php": "^7.0" 1444 | }, 1445 | "type": "library", 1446 | "autoload": { 1447 | "classmap": [ 1448 | "src/" 1449 | ] 1450 | }, 1451 | "notification-url": "https://packagist.org/downloads/", 1452 | "license": [ 1453 | "BSD-3-Clause" 1454 | ], 1455 | "authors": [ 1456 | { 1457 | "name": "Arne Blankerts", 1458 | "email": "arne@blankerts.de", 1459 | "role": "Developer" 1460 | } 1461 | ], 1462 | "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", 1463 | "time": "2017-04-07T12:08:54+00:00" 1464 | }, 1465 | { 1466 | "name": "webmozart/assert", 1467 | "version": "1.3.0", 1468 | "source": { 1469 | "type": "git", 1470 | "url": "https://github.com/webmozart/assert.git", 1471 | "reference": "0df1908962e7a3071564e857d86874dad1ef204a" 1472 | }, 1473 | "dist": { 1474 | "type": "zip", 1475 | "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", 1476 | "reference": "0df1908962e7a3071564e857d86874dad1ef204a", 1477 | "shasum": "" 1478 | }, 1479 | "require": { 1480 | "php": "^5.3.3 || ^7.0" 1481 | }, 1482 | "require-dev": { 1483 | "phpunit/phpunit": "^4.6", 1484 | "sebastian/version": "^1.0.1" 1485 | }, 1486 | "type": "library", 1487 | "extra": { 1488 | "branch-alias": { 1489 | "dev-master": "1.3-dev" 1490 | } 1491 | }, 1492 | "autoload": { 1493 | "psr-4": { 1494 | "Webmozart\\Assert\\": "src/" 1495 | } 1496 | }, 1497 | "notification-url": "https://packagist.org/downloads/", 1498 | "license": [ 1499 | "MIT" 1500 | ], 1501 | "authors": [ 1502 | { 1503 | "name": "Bernhard Schussek", 1504 | "email": "bschussek@gmail.com" 1505 | } 1506 | ], 1507 | "description": "Assertions to validate method input/output with nice error messages.", 1508 | "keywords": [ 1509 | "assert", 1510 | "check", 1511 | "validate" 1512 | ], 1513 | "time": "2018-01-29T19:49:41+00:00" 1514 | } 1515 | ], 1516 | "aliases": [], 1517 | "minimum-stability": "stable", 1518 | "stability-flags": [], 1519 | "prefer-stable": false, 1520 | "prefer-lowest": false, 1521 | "platform": { 1522 | "php": ">=7.1" 1523 | }, 1524 | "platform-dev": [] 1525 | } 1526 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | tests 9 | 10 | 11 | 12 | 13 | src 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Exception.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class Geolocation 16 | { 17 | const API_URL = 'maps.googleapis.com/maps/api/geocode/json'; 18 | 19 | /** @var string */ 20 | private $apiKey; 21 | 22 | /** @var bool */ 23 | private $https; 24 | 25 | public function __construct(string $apiKey = null, bool $https = true) 26 | { 27 | $this->https = $https; 28 | 29 | if ($apiKey !== null) { 30 | $this->apiKey = $apiKey; 31 | $this->https = true; 32 | } 33 | } 34 | 35 | private function createUrl(array $parameters): string 36 | { 37 | // define url 38 | $url = ($this->https ? 'https://' : 'http://') . self::API_URL . '?'; 39 | 40 | // add every parameter to the url 41 | foreach ($parameters as $key => $value) { 42 | $url .= $key . '=' . urlencode($value) . '&'; 43 | } 44 | 45 | // trim last & 46 | $url = trim($url, '&'); 47 | 48 | if ($this->apiKey) { 49 | $url .= '&key=' . $this->apiKey; 50 | } 51 | 52 | return $url; 53 | } 54 | 55 | /** 56 | * Do call 57 | * 58 | * @param array $parameters 59 | * @return mixed 60 | * @throws Exception 61 | */ 62 | protected function doCall(array $parameters = array()) 63 | { 64 | // check if curl is available 65 | if (!function_exists('curl_init')) { 66 | throw Exception::CurlNotInstalled(); 67 | } 68 | 69 | // init curl 70 | $curl = curl_init(); 71 | 72 | // set options 73 | curl_setopt($curl, CURLOPT_URL, $this->createUrl($parameters)); 74 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 75 | curl_setopt($curl, CURLOPT_TIMEOUT, 10); 76 | if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') { 77 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); 78 | } 79 | 80 | // execute 81 | $response = curl_exec($curl); 82 | 83 | // fetch errors 84 | $errorNumber = curl_errno($curl); 85 | $errorMessage = curl_error($curl); 86 | 87 | // close curl 88 | curl_close($curl); 89 | 90 | // we have errors 91 | if ($errorNumber != '') { 92 | throw new Exception($errorMessage); 93 | } 94 | 95 | // redefine response as json decoded 96 | $response = json_decode($response); 97 | 98 | // API returns with an error 99 | if (isset($response->error_message)) { 100 | throw new Exception($response->error_message); 101 | } 102 | 103 | // return the content 104 | return $response->results; 105 | } 106 | 107 | /** 108 | * Get address using latitude/longitude 109 | * 110 | * @param float $latitude 111 | * @param float $longitude 112 | * @return Address 113 | * @throws Exception 114 | */ 115 | public function getAddress(float $latitude, float $longitude): Address 116 | { 117 | $addressSuggestions = $this->getAddresses($latitude, $longitude); 118 | 119 | if (count($addressSuggestions) == 0) { 120 | throw Exception::noAddressFoundForCoordinates($latitude, $longitude); 121 | } 122 | 123 | return $addressSuggestions[0]; 124 | } 125 | 126 | /** 127 | * Get possible addresses using latitude/longitude 128 | * 129 | * @param float $latitude 130 | * @param float $longitude 131 | * @return array 132 | * @throws Exception 133 | */ 134 | public function getAddresses(float $latitude, float $longitude): ?array 135 | { 136 | // init results 137 | $addresses = []; 138 | 139 | // define result 140 | $addressSuggestions = $this->doCall(array( 141 | 'latlng' => $latitude . ',' . $longitude, 142 | 'sensor' => 'false' 143 | )); 144 | 145 | // loop addresses 146 | foreach ($addressSuggestions as $key => $addressSuggestion) { 147 | $addresses[$key] = Address::createFromGoogleResult($addressSuggestion); 148 | } 149 | 150 | return $addresses; 151 | } 152 | 153 | /** 154 | * Get coordinates latitude/longitude 155 | * 156 | * @param null|string $street 157 | * @param null|string $streetNumber 158 | * @param null|string $city 159 | * @param null|string $zip 160 | * @param null|string $country 161 | * @return Coordinates 162 | * @throws Exception 163 | */ 164 | public function getCoordinates( 165 | ?string $street = null, 166 | ?string $streetNumber = null, 167 | ?string $city = null, 168 | ?string $zip = null, 169 | ?string $country = null 170 | ): Coordinates { 171 | $items = []; 172 | $variables = [$street, $streetNumber, $city, $zip, $country]; 173 | foreach ($variables as $variable) { 174 | if (empty($variable)) { 175 | continue; 176 | } 177 | 178 | $items[] = $variable; 179 | } 180 | 181 | $results = $this->doCall(array( 182 | 'address' => implode(' ', $items), 183 | 'sensor' => 'false' 184 | )); 185 | 186 | if (!array_key_exists(0, $results)) { 187 | throw Exception::noCoordinatesFoundforAddress($variables); 188 | } 189 | 190 | return new Coordinates( 191 | $results[0]->geometry->location->lat, 192 | $results[0]->geometry->location->lng 193 | ); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /src/Result/Address.php: -------------------------------------------------------------------------------- 1 | addressComponents = $result; 18 | $this->label = $label; 19 | } 20 | 21 | public static function createFromGoogleResult(\stdClass $result): Address 22 | { 23 | return new self( 24 | $result, 25 | $result->formatted_address ?? null 26 | ); 27 | } 28 | 29 | public function getResult(): \stdClass 30 | { 31 | return $this->result; 32 | } 33 | 34 | public function getLabel(): ?string 35 | { 36 | return $this->label; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Result/Coordinates.php: -------------------------------------------------------------------------------- 1 | latitude = $latitude; 13 | $this->longitude = $longitude; 14 | } 15 | 16 | /** 17 | * @return mixed 18 | */ 19 | public function getLatitude() 20 | { 21 | return $this->latitude; 22 | } 23 | 24 | /** 25 | * @return mixed 26 | */ 27 | public function getLongitude() 28 | { 29 | return $this->longitude; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/GeolocationTest.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class GeolocationTest extends TestCase 24 | { 25 | /** @var Geolocation */ 26 | private $api; 27 | 28 | public function setUp(): void 29 | { 30 | $this->api = new Geolocation(); 31 | } 32 | 33 | /** 34 | * Test getting latitude/longitude coordinates from address. 35 | */ 36 | public function testGettingLatitudeAndLongitudeFromAddress(): void 37 | { 38 | $street = 'Koningin Maria Hendrikaplein'; 39 | $streetNumber = '1'; 40 | $city = 'Gent'; 41 | $zip = '1'; 42 | $country = 'belgium'; 43 | 44 | $result = $this->api->getCoordinates( 45 | $street, 46 | $streetNumber, 47 | $city, 48 | $zip, 49 | $country 50 | ); 51 | 52 | $this->assertEquals(51.037249600000003, $result->getLatitude()); 53 | $this->assertEquals(3.7094974999999999, $result->getLongitude()); 54 | } 55 | 56 | /** 57 | * Test getting address from latitude and longitude coordinates. 58 | */ 59 | public function testGetAddressFromLatitudeAndLongitude(): void 60 | { 61 | $latitude = 51.0363935; 62 | $longitude = 3.7121008; 63 | 64 | $result = $this->api->getAddress( 65 | $latitude, 66 | $longitude 67 | ); 68 | 69 | $this->assertEquals('Pr. Clementinalaan 114-140, 9000 Gent, Belgium', $result->getLabel()); 70 | } 71 | 72 | /** 73 | * Test getting latitude/longitude coordinates from address. 74 | */ 75 | public function testGettingLatitudeAndLongitudeFromAddressWithoutHTTPS(): void 76 | { 77 | $this->api = new Geolocation(null, false); 78 | $this->testGettingLatitudeAndLongitudeFromAddress(); 79 | } 80 | 81 | /** 82 | * Test getting address from latitude and longitude coordinates. 83 | */ 84 | public function testGetAddressFromLatitudeAndLongitudeWithoutHTTPS(): void 85 | { 86 | $this->api = new Geolocation(null, false); 87 | $this->testGetAddressFromLatitudeAndLongitude(); 88 | } 89 | } 90 | --------------------------------------------------------------------------------