Skip to content

Commit ff02e54

Browse files
authored
Update the readme (#704)
* Improving the readme * More docs updates * More readme * Minor fixes * Minor fixes * minor * Minor * MInor * Alwasy use snake_case on provider name * Added docs about stateful geocoder * Bugfix * Bugfix
1 parent 8c5755d commit ff02e54

File tree

11 files changed

+145
-257
lines changed

11 files changed

+145
-257
lines changed

README.md

Lines changed: 79 additions & 233 deletions
Large diffs are not rendered by default.

src/Common/ProviderAggregator.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ProviderAggregator implements Geocoder
4141
/**
4242
* @param int $limit
4343
*/
44-
public function __construct($limit = Geocoder::DEFAULT_RESULT_LIMIT)
44+
public function __construct(int $limit = Geocoder::DEFAULT_RESULT_LIMIT)
4545
{
4646
$this->limit($limit);
4747
}
@@ -67,7 +67,7 @@ public function reverseQuery(ReverseQuery $query): Collection
6767
*/
6868
public function getName(): string
6969
{
70-
return 'ProviderAggregator';
70+
return 'provider_aggregator';
7171
}
7272

7373
/**
@@ -89,19 +89,21 @@ public function reverse($latitude, $longitude): Collection
8989
}
9090

9191
/**
92-
* {@inheritdoc}
92+
* @param $limit
93+
*
94+
* @return $this
9395
*/
94-
public function limit($limit)
96+
public function limit(int $limit): self
9597
{
9698
$this->limit = $limit;
9799

98100
return $this;
99101
}
100102

101103
/**
102-
* {@inheritdoc}
104+
* @return int
103105
*/
104-
public function getLimit()
106+
public function getLimit(): int
105107
{
106108
return $this->limit;
107109
}
@@ -113,7 +115,7 @@ public function getLimit()
113115
*
114116
* @return ProviderAggregator
115117
*/
116-
public function registerProvider(Provider $provider)
118+
public function registerProvider(Provider $provider): self
117119
{
118120
$this->providers[$provider->getName()] = $provider;
119121

@@ -127,7 +129,7 @@ public function registerProvider(Provider $provider)
127129
*
128130
* @return ProviderAggregator
129131
*/
130-
public function registerProviders(array $providers = [])
132+
public function registerProviders(array $providers = []): self
131133
{
132134
foreach ($providers as $provider) {
133135
$this->registerProvider($provider);
@@ -143,7 +145,7 @@ public function registerProviders(array $providers = [])
143145
*
144146
* @return ProviderAggregator
145147
*/
146-
public function using($name)
148+
public function using(string $name): self
147149
{
148150
if (!isset($this->providers[$name])) {
149151
throw new ProviderNotRegistered($name ?? '');
@@ -159,7 +161,7 @@ public function using($name)
159161
*
160162
* @return Provider[]
161163
*/
162-
public function getProviders()
164+
public function getProviders(): array
163165
{
164166
return $this->providers;
165167
}
@@ -168,8 +170,10 @@ public function getProviders()
168170
* Returns the current provider in use.
169171
*
170172
* @return Provider
173+
*
174+
* @throws \RuntimeException
171175
*/
172-
protected function getProvider()
176+
protected function getProvider(): Provider
173177
{
174178
if (null === $this->provider) {
175179
if (0 === count($this->providers)) {

src/Common/StatefulGeocoder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function reverseQuery(ReverseQuery $query): Collection
124124
*
125125
* @return StatefulGeocoder
126126
*/
127-
public function setLocale(string $locale): StatefulGeocoder
127+
public function setLocale(string $locale): self
128128
{
129129
$this->locale = $locale;
130130

@@ -136,7 +136,7 @@ public function setLocale(string $locale): StatefulGeocoder
136136
*
137137
* @return StatefulGeocoder
138138
*/
139-
public function setBounds(Bounds $bounds): StatefulGeocoder
139+
public function setBounds(Bounds $bounds): self
140140
{
141141
$this->bounds = $bounds;
142142

@@ -148,7 +148,7 @@ public function setBounds(Bounds $bounds): StatefulGeocoder
148148
*
149149
* @return StatefulGeocoder
150150
*/
151-
public function setLimit(int $limit): StatefulGeocoder
151+
public function setLimit(int $limit): self
152152
{
153153
$this->limit = $limit;
154154

src/Common/Tests/ProviderAggregatorTest.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ public function testUsingNonExistantProviderShouldThrowAnException()
7878
$this->geocoder->using('non_existant');
7979
}
8080

81-
/**
82-
* @expectedException \Geocoder\Exception\ProviderNotRegistered
83-
*/
84-
public function testUsingNullShouldThrowAnException()
85-
{
86-
$this->geocoder->using(null);
87-
}
88-
8981
/**
9082
* @expectedException \Geocoder\Exception\ProviderNotRegistered
9183
*/
@@ -207,7 +199,7 @@ class TestableGeocoder extends ProviderAggregator
207199
{
208200
public $countCallGetProvider = 0;
209201

210-
public function getProvider()
202+
public function getProvider(): Provider
211203
{
212204
++$this->countCallGetProvider;
213205

src/Common/TimedGeocoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ public function __call($method, $args)
8989

9090
public function getName(): string
9191
{
92-
return 'TimedGeocoder';
92+
return 'timed_geocoder';
9393
}
9494
}

src/Provider/ArcGISOnline/Readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ This is the ArcGIS provider from the PHP Geocoder. This is a **READ ONLY** repos
1616
composer require geocoder-php/arcgis-online-provider
1717
```
1818

19+
### Note
20+
21+
It is possible to specify a `sourceCountry` to restrict result to this specific
22+
country thus reducing request time (note that this doesn't work on reverse
23+
geocoding).
24+
25+
1926
### Contribute
2027

2128
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or

src/Provider/GeoIP2/Readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ This is the GeoIP2 provider from the PHP Geocoder. This is a **READ ONLY** repos
1515
composer require geocoder-php/geoip2-provider
1616
```
1717

18+
### Note
19+
20+
It requires either the [database file](http://dev.maxmind.com/geoip/geoip2/geolite2/), or the
21+
[webservice](http://dev.maxmind.com/geoip/geoip2/web-services/) - represented by
22+
the GeoIP2 , which is injected to the `GeoIP2Adapter`.
23+
24+
This provider will only work with the corresponding `GeoIP2Adapter`:
25+
26+
``` php
27+
// Maxmind GeoIP2 Provider: e.g. the database reader
28+
$reader = new \GeoIp2\Database\Reader('/path/to/database');
29+
30+
$adapter = new \Geocoder\Adapter\GeoIP2Adapter($reader);
31+
$geocoder = new \Geocoder\Provider\GeoIP2($adapter);
32+
33+
$address = $geocoder->geocode('74.200.247.59')->first();
34+
```
35+
1836
### Contribute
1937

2038
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or

src/Provider/GoogleMaps/Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ This is the Google Maps provider from the PHP Geocoder. This is a **READ ONLY**
1515
composer require geocoder-php/google-maps-provider
1616
```
1717

18+
### Note
19+
20+
A valid `Client ID` is required for GoogleMaps for Business. The private key is optional.
21+
1822
### Contribute
1923

2024
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or

src/Provider/MaxMindBinary/Readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ This is the MaxMind Binary provider from the PHP Geocoder. This is a **READ ONLY
1515
composer require geocoder-php/maxmind-binary-provider
1616
```
1717

18+
### Note
19+
20+
This provider requires a data file.
21+
1822
### Contribute
1923

2024
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or

src/Provider/TomTom/Readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ This is the TomTom provider from the PHP Geocoder. This is a **READ ONLY** repos
1515
composer require geocoder-php/tomtom-provider
1616
```
1717

18+
### Note
19+
20+
The default language-locale is `en`, you can choose between `de`, `es`, `fr`,
21+
`it`, `nl`, `pl`, `pt` and `sv`.
22+
1823
### Contribute
1924

2025
Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or

0 commit comments

Comments
 (0)