Skip to content

Commit 1b0014e

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 5dfd0ef commit 1b0014e

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

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)) {

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

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

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
}

0 commit comments

Comments
 (0)