Skip to content

Commit 22e778d

Browse files
author
Martin Brecht-Precht
committed
Updated the root namespace and the vendor prefix
1 parent b0e5e60 commit 22e778d

12 files changed

+101
-100
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
3+
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# PHP Google Geocoder
22

3-
[![Build Status](https://travis-ci.org/markenwerk/php-google-geocoder.svg?branch=master)](https://travis-ci.org/markenwerk/php-google-geocoder)
4-
[![Test Coverage](https://codeclimate.com/github/markenwerk/php-google-geocoder/badges/coverage.svg)](https://codeclimate.com/github/markenwerk/php-google-geocoder/coverage)
3+
[![Build Status](https://travis-ci.org/chroma-x/php-google-geocoder.svg?branch=master)](https://travis-ci.org/chroma-x/php-google-geocoder)
4+
[![Test Coverage](https://codeclimate.com/github/chroma-x/php-google-geocoder/badges/coverage.svg)](https://codeclimate.com/github/chroma-x/php-google-geocoder/coverage)
55
[![Dependency Status](https://www.versioneye.com/user/projects/571f7841fcd19a004544233f/badge.svg)](https://www.versioneye.com/user/projects/571f7841fcd19a004544233f)
6-
[![Code Climate](https://codeclimate.com/github/markenwerk/php-google-geocoder/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-google-geocoder)
7-
[![Latest Stable Version](https://poser.pugx.org/markenwerk/google-geocoder/v/stable)](https://packagist.org/packages/markenwerk/google-geocoder)
8-
[![Total Downloads](https://poser.pugx.org/markenwerk/google-geocoder/downloads)](https://packagist.org/packages/markenwerk/google-geocoder)
9-
[![License](https://poser.pugx.org/markenwerk/google-geocoder/license)](https://packagist.org/packages/markenwerk/google-geocoder)
6+
[![Code Climate](https://codeclimate.com/github/chroma-x/php-google-geocoder/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-google-geocoder)
7+
[![Latest Stable Version](https://poser.pugx.org/chroma-x/google-geocoder/v/stable)](https://packagist.org/packages/chroma-x/google-geocoder)
8+
[![Total Downloads](https://poser.pugx.org/chroma-x/google-geocoder/downloads)](https://packagist.org/packages/chroma-x/google-geocoder)
9+
[![License](https://poser.pugx.org/chroma-x/google-geocoder/license)](https://packagist.org/packages/chroma-x/google-geocoder)
1010

1111
A PHP library to query Google's location service for geolocation and reverse lookups based on a given address, a geo location or a Google Places ID.
1212

@@ -15,7 +15,7 @@ A PHP library to query Google's location service for geolocation and reverse loo
1515
```{json}
1616
{
1717
"require": {
18-
"markenwerk/google-geocoder": "~3.0"
18+
"chroma-x/google-geocoder": "~3.0"
1919
}
2020
}
2121
```
@@ -35,20 +35,20 @@ require_once('path/to/vendor/autoload.php');
3535
#### Resolving an address
3636

3737
```{php}
38-
use Markenwerk\CommonException;
38+
use ChromaX\CommonException;
3939
4040
try{
4141
// Perform lookup
42-
$addressLookup = new Markenwerk\GoogleGeocode\Lookup\AddressLookup();
42+
$addressLookup = new ChromaX\GoogleGeocode\Lookup\AddressLookup();
4343
$addressLookup->lookup('Germany, 24105 Kiel, Lornsenstraße 43');
4444
45-
// Retrieving the lookup as an array of Markenwerk\GoogleGeocode\Result\GeoLookupResult instances
45+
// Retrieving the lookup as an array of ChromaX\GoogleGeocode\Result\GeoLookupResult instances
4646
$lookupResults = $addressLookup->getResults();
4747
4848
// Get the number of lookup results
4949
$lookupResultCount = $addressLookup->getResultCount();
5050
51-
// Retrieving the first lookup result as Markenwerk\GoogleGeocode\Result\GeoLookupResult instance
51+
// Retrieving the first lookup result as ChromaX\GoogleGeocode\Result\GeoLookupResult instance
5252
$firstResult = $addressLookup->getFirstResult();
5353
5454
} catch (CommonException\NetworkException\CurlException $exception) {
@@ -66,20 +66,20 @@ try{
6666
#### Resolving a geo location
6767

6868
```{php}
69-
use Markenwerk\CommonException;
69+
use ChromaX\CommonException;
7070
7171
try{
7272
// Perform lookup
73-
$geoLocationLookup = new Markenwerk\GoogleGeocode\Lookup\GeoLocationLookup();
73+
$geoLocationLookup = new ChromaX\GoogleGeocode\Lookup\GeoLocationLookup();
7474
$geoLocationLookup->lookup(54.334123, 10.1364007);
7575
76-
// Retrieving the lookup as an array of Markenwerk\GoogleGeocode\Result\GeoLookupResult instances
76+
// Retrieving the lookup as an array of ChromaX\GoogleGeocode\Result\GeoLookupResult instances
7777
$lookupResults = $geoLocationLookup->getResults();
7878
7979
// Get the number of lookup results
8080
$lookupResultCount = $geoLocationLookup->getResultCount();
8181
82-
// Retrieving the first lookup result as Markenwerk\GoogleGeocode\Result\AddressLookupResult instance
82+
// Retrieving the first lookup result as ChromaX\GoogleGeocode\Result\AddressLookupResult instance
8383
$firstResult = $geoLocationLookup->getFirstResult();
8484
8585
} catch (CommonException\NetworkException\CurlException $exception) {
@@ -99,22 +99,22 @@ try{
9999
Resolving Google Places IDs utilizes the Google Places API. Therefore a Places API key is mandatory for performing a lookup. Please visit the [Google API console](https://console.developers.google.com/apis/api/geocoding_backend?project=_) to receive an API key.
100100

101101
```{php}
102-
use Markenwerk\CommonException;
102+
use ChromaX\CommonException;
103103
104104
try{
105105
// Perform lookup
106-
$googlePlacesLookup = new Markenwerk\GoogleGeocode\Lookup\GooglePlacesLookup();
106+
$googlePlacesLookup = new ChromaX\GoogleGeocode\Lookup\GooglePlacesLookup();
107107
$googlePlacesLookup
108108
->setApiKey('MY_GOOGLE_PLACES_API_KEY')
109109
->lookup('ChIJ_zNzWmpWskcRP8DWT5eX5jQ');
110110
111-
// Retrieving the lookup as an array of Markenwerk\GoogleGeocode\Result\GeoLookupResult instances
111+
// Retrieving the lookup as an array of ChromaX\GoogleGeocode\Result\GeoLookupResult instances
112112
$lookupResults = $googlePlacesLookup->getResults();
113113
114114
// Get the number of lookup results
115115
$lookupResultCount = $googlePlacesLookup->getResultCount();
116116
117-
// Retrieving the first lookup result as Markenwerk\GoogleGeocode\Result\AddressLookupResult instance
117+
// Retrieving the first lookup result as ChromaX\GoogleGeocode\Result\AddressLookupResult instance
118118
$firstResult = $googlePlacesLookup->getFirstResult();
119119
120120
} catch (CommonException\NetworkException\CurlException $exception) {
@@ -138,10 +138,10 @@ try{
138138
**Attention:** Plaese note that all getter methods on the `GeoLocationAddress` return a `GeoLocationAddressComponent` instance or `null`. For preventing calls on non-objects the `GeoLocationAddress` class provides methods to check whether the address components exists.
139139

140140
```{php}
141-
// Retrieving the first lookup result as Markenwerk\GoogleGeocode\Result\GeoLookupResult instance
141+
// Retrieving the first lookup result as ChromaX\GoogleGeocode\Result\GeoLookupResult instance
142142
$firstResult = $addressLookup->getFirstResult();
143143
144-
// Retieving address information as Markenwerk\GoogleGeocode\GeoLocation\GeoLocationAddress
144+
// Retieving address information as ChromaX\GoogleGeocode\GeoLocation\GeoLocationAddress
145145
$geoLocationAddress = $firstResult->getAddress();
146146
147147
if($firstResult->hasAddress()) {
@@ -233,13 +233,13 @@ if($firstResult->hasGooglePlacesId()) {
233233
## Exception handling
234234

235235
PHP Google Geocoder provides different exceptions provided by the PHP Common Exceptions project for proper handling.
236-
You can find more information about [PHP Common Exceptions at Github](https://github.com/markenwerk/php-common-exceptions).
236+
You can find more information about [PHP Common Exceptions at Github](https://github.com/chroma-x/php-common-exceptions).
237237

238238
## Contribution
239239

240240
Contributing to our projects is always very appreciated.
241-
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/markenwerk/php-google-geocoder/blob/master/CONTRIBUTING.md) document.**
241+
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-google-geocoder/blob/master/CONTRIBUTING.md) document.**
242242

243243
## License
244244

245-
PHP Google Geocoder is under the MIT license.
245+
PHP Google Geocoder is under the MIT license.

composer.json

+34-35
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
{
2-
"name": "markenwerk/google-geocoder",
3-
"type": "library",
4-
"description": "A PHP library to query Google's location service for geolocation and reverse lookups based on a given address, a geo location or a Google Places ID.",
5-
"keywords": [
6-
"Google",
7-
"Geolocation",
8-
"Geolookup"
9-
],
10-
"homepage": "http://markenwerk.net/",
11-
"license": "MIT",
12-
"authors": [
13-
{
14-
"name": "Martin Brecht-Precht",
15-
"email": "[email protected]",
16-
"homepage": "http://markenwerk.net"
17-
}
18-
],
19-
"autoload": {
20-
"psr-4": {
21-
"Markenwerk\\GoogleGeocode\\": "src/"
22-
}
23-
},
24-
"require": {
25-
"php": ">=5.3",
26-
"lib-curl": "*",
27-
"markenwerk/common-exceptions": "~3.0",
28-
"markenwerk/google-datastructures": "~2.0"
29-
},
30-
"require-dev":{
31-
"phpunit/phpunit": "~4.8",
32-
"codeclimate/php-test-reporter": "dev-master"
33-
},
34-
"suggest": {
35-
"markenwerk/google-places-suite": "A PHP library to query Google's Places service for querying locations and addresses and getting details by Places ID."
36-
}
2+
"name": "chroma-x/google-geocoder",
3+
"type": "library",
4+
"description": "A PHP library to query Google's location service for geolocation and reverse lookups based on a given address, a geo location or a Google Places ID.",
5+
"keywords": [
6+
"Google",
7+
"Geolocation",
8+
"Geolookup"
9+
],
10+
"homepage": "http://chroma-x.de/",
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Martin Brecht-Precht",
15+
"email": "[email protected]",
16+
"homepage": "http://chroma-x.de"
17+
}
18+
],
19+
"autoload": {
20+
"psr-4": {
21+
"ChromaX\\GoogleGeocode\\": "src/"
22+
}
23+
},
24+
"require": {
25+
"php": ">=5.3",
26+
"ext-curl": "*",
27+
"lib-curl": "*",
28+
"ext-json": "*",
29+
"chroma-x/common-exceptions": "~3.0",
30+
"chroma-x/google-datastructures": "~2.0"
31+
},
32+
"require-dev": {
33+
"phpunit/phpunit": "~4.8",
34+
"codeclimate/php-test-reporter": "dev-master"
35+
}
3736
}

src/Lookup/AbstractApiKeyGatedLookup.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\GoogleGeocode;
5+
use ChromaX\GoogleGeocode;
66

77
/**
88
* Class AbstractApiKeyGatedLookup
99
*
10-
* @package Markenwerk\GoogleGeocode\Lookup
10+
* @package ChromaX\GoogleGeocode\Lookup
1111
*/
1212
abstract class AbstractApiKeyGatedLookup extends AbstractLookup
1313
{

src/Lookup/AbstractLookup.php

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\CommonException;
6-
use Markenwerk\GoogleGeocode;
7-
use Markenwerk\GoogleDataStructure;
5+
use ChromaX\CommonException;
6+
use ChromaX\GoogleDataStructure\GeoLocation\GeoLocationAddress;
7+
use ChromaX\GoogleDataStructure\GeoLocation\GeoLocationGeometry;
8+
use ChromaX\GoogleGeocode;
9+
use ChromaX\GoogleGeocode\Result\GeoLookupResult;
810

911
/**
1012
* Class AbstractLookup
1113
*
12-
* @package Markenwerk\GoogleGeocode\Lookup
14+
* @package ChromaX\GoogleGeocode\Lookup
1315
*/
1416
abstract class AbstractLookup
1517
{
@@ -61,7 +63,7 @@ public function getResultCount()
6163
*/
6264
public function getFirstResult()
6365
{
64-
if (count($this->results) == 0) {
66+
if (count($this->results) === 0) {
6567
return null;
6668
}
6769
return $this->results[0];
@@ -108,13 +110,13 @@ private function validateResponse($rawResponse, $responseData)
108110
}
109111

110112
$responseStatus = mb_strtoupper($responseData['status']);
111-
if ($responseStatus == 'OVER_QUERY_LIMIT') {
113+
if ($responseStatus === 'OVER_QUERY_LIMIT') {
112114
$exceptionMessage = $this->buildExceptionMessage('Google Geocoder request limit reached', $responseData);
113115
throw new CommonException\ApiException\RequestQuotaException($exceptionMessage);
114-
} else if ($responseStatus == 'REQUEST_DENIED') {
116+
} else if ($responseStatus === 'REQUEST_DENIED') {
115117
$exceptionMessage = $this->buildExceptionMessage('Google Geocoder request was denied', $responseData);
116118
throw new CommonException\ApiException\AuthenticationException($exceptionMessage);
117-
} else if ($responseStatus != 'OK') {
119+
} else if ($responseStatus !== 'OK') {
118120
$exceptionMessage = $this->buildExceptionMessage('Google Geocoder no results', $responseData);
119121
throw new CommonException\ApiException\NoResultException($exceptionMessage);
120122
}
@@ -139,15 +141,15 @@ private function buildExceptionMessage($exceptionMessage, array $responseData)
139141
*/
140142
protected function addResultsFromResponse($responseData)
141143
{
142-
for ($i = 0; $i < count($responseData['results']); $i++) {
144+
for ($i = 0, $n = count($responseData['results']); $i < $n; $i++) {
143145
$address = $responseData['results'][$i]['address_components'];
144146
$geometry = $responseData['results'][$i]['geometry'];
145147
$placesId = $responseData['results'][$i]['place_id'];
146-
$locationAddress = new GoogleDataStructure\GeoLocation\GeoLocationAddress();
148+
$locationAddress = new GeoLocationAddress();
147149
$locationAddress->setFromServiceResult($address);
148-
$locationGeometry = new GoogleDataStructure\GeoLocation\GeoLocationGeometry();
150+
$locationGeometry = new GeoLocationGeometry();
149151
$locationGeometry->setFromServiceResult($geometry);
150-
$this->addResult(new GoogleGeocode\Result\GeoLookupResult($locationAddress, $locationGeometry, $placesId));
152+
$this->addResult(new GeoLookupResult($locationAddress, $locationGeometry, $placesId));
151153
}
152154
return $this;
153155
}

src/Lookup/AddressLookup.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\CommonException;
5+
use ChromaX\CommonException;
66

77
/**
88
* Class AddressLookup
99
*
10-
* @package Markenwerk\GoogleGeocode\Lookup
10+
* @package ChromaX\GoogleGeocode\Lookup
1111
*/
1212
class AddressLookup extends AbstractLookup
1313
{

src/Lookup/GeoLocationLookup.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\CommonException;
5+
use ChromaX\CommonException;
66

77
/**
88
* Class GeoLocationLookup
99
*
10-
* @package Markenwerk\GoogleGeocode\Lookup
10+
* @package ChromaX\GoogleGeocode\Lookup
1111
*/
1212
class GeoLocationLookup extends AbstractLookup
1313
{

src/Lookup/GooglePlacesLookup.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\CommonException;
5+
use ChromaX\CommonException;
66

77
/**
88
* Class GooglePlacesLookup
99
*
10-
* @package Markenwerk\GoogleGeocode\Lookup
10+
* @package ChromaX\GoogleGeocode\Lookup
1111
*/
1212
class GooglePlacesLookup extends AbstractApiKeyGatedLookup
1313
{

src/Result/GeoLookupResult.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Result;
3+
namespace ChromaX\GoogleGeocode\Result;
44

5-
use Markenwerk\GoogleDataStructure\GeoLocation;
5+
use ChromaX\GoogleDataStructure\GeoLocation;
66

77
/**
88
* Class GeoLookupResult
99
*
10-
* @package Markenwerk\GoogleGeocode\Result
10+
* @package ChromaX\GoogleGeocode\Result
1111
*/
1212
class GeoLookupResult
1313
{

test/AddressLookupTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Markenwerk\GoogleGeocode\Lookup;
3+
namespace ChromaX\GoogleGeocode\Lookup;
44

5-
use Markenwerk\CommonException;
5+
use ChromaX\CommonException;
66

77
/**
88
* Class AddressLookupTest
99
*
10-
* @package Markenwerk\GoogleGeocode
10+
* @package ChromaX\GoogleGeocode
1111
*/
1212
class AddressLookupTest extends \PHPUnit_Framework_TestCase
1313
{
@@ -21,7 +21,7 @@ public function testLookupSuccess()
2121
// Validate results
2222
$this->assertEquals(1, $addressLookup->getResultCount());
2323
$firstResult = $addressLookup->getFirstResult();
24-
$this->assertInstanceOf('Markenwerk\\GoogleGeocode\\Result\\GeoLookupResult', $firstResult);
24+
$this->assertInstanceOf('ChromaX\\GoogleGeocode\\Result\\GeoLookupResult', $firstResult);
2525

2626
// Address result
2727
$this->assertTrue($firstResult->hasAddress());

0 commit comments

Comments
 (0)