Skip to content

Commit d11ce3f

Browse files
author
Martin Brecht-Precht
committed
Updated dependencies.
Updated readme. Refactored some code.
1 parent 885eb56 commit d11ce3f

11 files changed

+64
-64
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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": "~2.0"
18+
"markenwerk/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 CommonException;
38+
use Markenwerk\CommonException;
3939
4040
try{
4141
// Perform lookup
42-
$addressLookup = new GoogleGeocode\AddressLookup();
42+
$addressLookup = new Markenwerk\GoogleGeocode\Lookup\AddressLookup();
4343
$addressLookup->lookup('Germany, 24105 Kiel, Lornsenstraße 43');
4444
45-
// Retrieving the lookup as an array of GoogleGeocode\GeoLookupResult instances
45+
// Retrieving the lookup as an array of Markenwerk\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 GoogleGeocode\GeoLookupResult instance
51+
// Retrieving the first lookup result as Markenwerk\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 CommonException;
69+
use Markenwerk\CommonException;
7070
7171
try{
7272
// Perform lookup
73-
$geoLocationLookup = new GoogleGeocode\GeoLocationLookup();
73+
$geoLocationLookup = new Markenwerk\GoogleGeocode\Lookup\GeoLocationLookup();
7474
$geoLocationLookup->lookup(54.334123, 10.1364007);
7575
76-
// Retrieving the lookup as an array of GoogleGeocode\GeoLookupResult instances
76+
// Retrieving the lookup as an array of Markenwerk\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 GoogleGeocode\AddressLookupResult instance
82+
// Retrieving the first lookup result as Markenwerk\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 CommonException;
102+
use Markenwerk\CommonException;
103103
104104
try{
105105
// Perform lookup
106-
$googlePlacesLookup = new GoogleGeocode\GooglePlacesLookup();
106+
$googlePlacesLookup = new 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 GoogleGeocode\GeoLookupResult instances
111+
// Retrieving the lookup as an array of Markenwerk\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 GoogleGeocode\AddressLookupResult instance
117+
// Retrieving the first lookup result as Markenwerk\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 GoogleGeocode\GeoLookupResult instance
141+
// Retrieving the first lookup result as Markenwerk\GoogleGeocode\Result\GeoLookupResult instance
142142
$firstResult = $addressLookup->getFirstResult();
143143
144-
// Retieving address information as GoogleGeocode\GeoLocation\GeoLocationAddress
144+
// Retieving address information as Markenwerk\GoogleGeocode\GeoLocation\GeoLocationAddress
145145
$geoLocationAddress = $firstResult->getAddress();
146146
147147
if($firstResult->hasAddress()) {

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
],
1919
"autoload": {
2020
"psr-4": {
21-
"GoogleGeocode\\": "src/"
21+
"Markenwerk\\GoogleGeocode\\": "src/"
2222
}
2323
},
2424
"require": {
2525
"php": ">=5.3",
2626
"lib-curl": "*",
27-
"markenwerk/common-exceptions": "~2.0",
28-
"markenwerk/google-datastructures": "~1.0"
27+
"markenwerk/common-exceptions": "~3.0",
28+
"markenwerk/google-datastructures": "~2.0"
2929
},
3030
"require-dev":{
3131
"phpunit/phpunit": "~4.8",

src/Base/BaseApiKeyGatedLookup.php renamed to src/Lookup/AbstractApiKeyGatedLookup.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

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

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

77
/**
8-
* Class BaseApiKeyGatedLookup
8+
* Class AbstractApiKeyGatedLookup
99
*
10-
* @package GoogleGeocode\Base
10+
* @package Markenwerk\GoogleGeocode\Lookup
1111
*/
12-
abstract class BaseApiKeyGatedLookup extends BaseLookup
12+
abstract class AbstractApiKeyGatedLookup extends AbstractLookup
1313
{
1414

1515
/**

src/Base/BaseLookup.php renamed to src/Lookup/AbstractLookup.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
<?php
22

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

5-
use CommonException;
6-
use GoogleGeocode;
7-
use GoogleDataStructure;
5+
use Markenwerk\CommonException;
6+
use Markenwerk\GoogleGeocode;
7+
use Markenwerk\GoogleDataStructure;
88

99
/**
10-
* Class BaseLookup
10+
* Class AbstractLookup
1111
*
12-
* @package GoogleGeocode\Base
12+
* @package Markenwerk\GoogleGeocode\Lookup
1313
*/
14-
abstract class BaseLookup
14+
abstract class AbstractLookup
1515
{
1616

1717
const API_BASE_URL = 'https://maps.google.com/maps/api/geocode/json?sensor=false';
1818

1919
/**
20-
* @var GoogleGeocode\GeoLookupResult[]
20+
* @var GoogleGeocode\Result\GeoLookupResult[]
2121
*/
2222
private $results = array();
2323

2424
/**
25-
* @param GoogleGeocode\GeoLookupResult $result
25+
* @param GoogleGeocode\Result\GeoLookupResult $result
2626
* @return $this
2727
*/
28-
protected function addResult(GoogleGeocode\GeoLookupResult $result)
28+
protected function addResult(GoogleGeocode\Result\GeoLookupResult $result)
2929
{
3030
$this->results[] = $result;
3131
return $this;
@@ -41,7 +41,7 @@ protected function clearResults()
4141
}
4242

4343
/**
44-
* @return GoogleGeocode\GeoLookupResult[]
44+
* @return GoogleGeocode\Result\GeoLookupResult[]
4545
*/
4646
public function getResults()
4747
{
@@ -57,7 +57,7 @@ public function getResultCount()
5757
}
5858

5959
/**
60-
* @return GoogleGeocode\GeoLookupResult
60+
* @return GoogleGeocode\Result\GeoLookupResult
6161
*/
6262
public function getFirstResult()
6363
{
@@ -147,7 +147,7 @@ protected function addResultsFromResponse($responseData)
147147
$locationAddress->setFromServiceResult($address);
148148
$locationGeometry = new GoogleDataStructure\GeoLocation\GeoLocationGeometry();
149149
$locationGeometry->setFromServiceResult($geometry);
150-
$this->addResult(new GoogleGeocode\GeoLookupResult($locationAddress, $locationGeometry, $placesId));
150+
$this->addResult(new GoogleGeocode\Result\GeoLookupResult($locationAddress, $locationGeometry, $placesId));
151151
}
152152
return $this;
153153
}

src/AddressLookup.php renamed to src/Lookup/AddressLookup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

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

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

77
/**
88
* Class AddressLookup
99
*
10-
* @package GoogleGeocode
10+
* @package Markenwerk\GoogleGeocode\Lookup
1111
*/
12-
class AddressLookup extends Base\BaseLookup
12+
class AddressLookup extends AbstractLookup
1313
{
1414

1515
/**

src/GeoLocationLookup.php renamed to src/Lookup/GeoLocationLookup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

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

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

77
/**
88
* Class GeoLocationLookup
99
*
10-
* @package GoogleGeocode
10+
* @package Markenwerk\GoogleGeocode\Lookup
1111
*/
12-
class GeoLocationLookup extends Base\BaseLookup
12+
class GeoLocationLookup extends AbstractLookup
1313
{
1414

1515
/**

src/GooglePlacesLookup.php renamed to src/Lookup/GooglePlacesLookup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

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

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

77
/**
88
* Class GooglePlacesLookup
99
*
10-
* @package GoogleGeocode
10+
* @package Markenwerk\GoogleGeocode\Lookup
1111
*/
12-
class GooglePlacesLookup extends Base\BaseApiKeyGatedLookup
12+
class GooglePlacesLookup extends AbstractApiKeyGatedLookup
1313
{
1414

1515
/**

src/GeoLookupResult.php renamed to src/Result/GeoLookupResult.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

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

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

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

test/AddressLookupTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

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

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

77
/**
88
* Class AddressLookupTest
99
*
10-
* @package GoogleGeocode
10+
* @package Markenwerk\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('GoogleGeocode\\GeoLookupResult', $firstResult);
24+
$this->assertInstanceOf('Markenwerk\\GoogleGeocode\\Result\\GeoLookupResult', $firstResult);
2525

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

test/GeoLocationLookupTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

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

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

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

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

test/GooglePlacesLookupTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

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

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

77
/**
88
* Class GooglePlacesLookupTest
99
*
10-
* @package GoogleGeocode
10+
* @package Markenwerk\GoogleGeocode
1111
*/
1212
class GooglePlacesLookupTest extends \PHPUnit_Framework_TestCase
1313
{
@@ -42,7 +42,7 @@ public function testLookupSuccess()
4242
// Validate results
4343
$this->assertEquals(1, $googlePlacesLookup->getResultCount());
4444
$firstResult = $googlePlacesLookup->getFirstResult();
45-
$this->assertInstanceOf('GoogleGeocode\\GeoLookupResult', $firstResult);
45+
$this->assertInstanceOf('Markenwerk\\GoogleGeocode\\Result\\GeoLookupResult', $firstResult);
4646

4747
// Address result
4848
$this->assertTrue($firstResult->hasAddress());

0 commit comments

Comments
 (0)