Skip to content

Commit a151049

Browse files
authored
Apply fixes from StyleCI (#1033)
1 parent 7d106e8 commit a151049

File tree

13 files changed

+20
-78
lines changed

13 files changed

+20
-78
lines changed

src/Common/Assert.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ private static function typeToString($value): string
6363
private static function float($value, string $message)
6464
{
6565
if (!is_float($value)) {
66-
throw new InvalidArgument(
67-
sprintf($message ?: 'Expected a float. Got: %s', self::typeToString($value))
68-
);
66+
throw new InvalidArgument(sprintf($message ?: 'Expected a float. Got: %s', self::typeToString($value)));
6967
}
7068
}
7169
}

src/Common/Model/AdminLevelCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ public function all(): array
132132
private function checkLevel(int $level)
133133
{
134134
if ($level <= 0 || $level > self::MAX_LEVEL_DEPTH) {
135-
throw new OutOfBounds(
136-
sprintf('Administrative level should be an integer in [1,%d], %d given', self::MAX_LEVEL_DEPTH, $level)
137-
);
135+
throw new OutOfBounds(sprintf('Administrative level should be an integer in [1,%d], %d given', self::MAX_LEVEL_DEPTH, $level));
138136
}
139137
}
140138
}

src/Provider/AlgoliaPlaces/AlgoliaPlaces.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ private function buildType(GeocodeQuery $query): string
143143
$type = $query->getData('type', '');
144144

145145
if (!empty($type) && !in_array($type, $this->getTypes())) {
146-
throw new InvalidArgument(
147-
sprintf('The type provided to AlgoliaPlace provider must be in `%s`', implode(', ', $this->getTypes()))
148-
);
146+
throw new InvalidArgument(sprintf('The type provided to AlgoliaPlace provider must be in `%s`', implode(', ', $this->getTypes())));
149147
}
150148

151149
return $type;

src/Provider/GeoIP2/GeoIP2.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,9 @@ private function executeQuery(string $address): string
117117
} catch (AddressNotFoundException $e) {
118118
return '';
119119
} catch (AuthenticationException $e) {
120-
throw new InvalidCredentials(
121-
$e->getMessage(),
122-
$e->getCode(),
123-
$e
124-
);
120+
throw new InvalidCredentials($e->getMessage(), $e->getCode(), $e);
125121
} catch (OutOfQueriesException $e) {
126-
throw new QuotaExceeded(
127-
$e->getMessage(),
128-
$e->getCode(),
129-
$e
130-
);
122+
throw new QuotaExceeded($e->getMessage(), $e->getCode(), $e);
131123
}
132124

133125
return $result;

src/Provider/GeoIP2/GeoIP2Adapter.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ public function __construct(ProviderInterface $geoIpProvider, $geoIP2Model = sel
4747
$this->geoIp2Provider = $geoIpProvider;
4848

4949
if (false === $this->isSupportedGeoIP2Model($geoIP2Model)) {
50-
throw new UnsupportedOperation(
51-
sprintf('Model "%s" is not available.', $geoIP2Model)
52-
);
50+
throw new UnsupportedOperation(sprintf('Model "%s" is not available.', $geoIP2Model));
5351
}
5452

5553
$this->geoIP2Model = $geoIP2Model;
@@ -65,9 +63,7 @@ public function __construct(ProviderInterface $geoIpProvider, $geoIP2Model = sel
6563
public function getContent(string $url): string
6664
{
6765
if (false === filter_var($url, FILTER_VALIDATE_URL)) {
68-
throw new InvalidArgument(
69-
sprintf('"%s" must be called with a valid url. Got "%s" instead.', __METHOD__, $url)
70-
);
66+
throw new InvalidArgument(sprintf('"%s" must be called with a valid url. Got "%s" instead.', __METHOD__, $url));
7167
}
7268

7369
$ipAddress = parse_url($url, PHP_URL_QUERY);

src/Provider/GeoIPs/GeoIPs.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,7 @@ private function executeQuery(string $url): AddressCollection
137137
case static::CODE_LIMIT_EXCEEDED:
138138
throw new QuotaExceeded('The service you have requested is over capacity.');
139139
default:
140-
throw new InvalidServerResponse(sprintf(
141-
'GeoIPs error %s%s%s%s - query: %s',
142-
$json['error']['code'],
143-
isset($json['error']['status']) ? ', '.$json['error']['status'] : '',
144-
isset($json['error']['message']) ? ', '.$json['error']['message'] : '',
145-
isset($json['error']['notes']) ? ', '.$json['error']['notes'] : '',
146-
$url
147-
));
140+
throw new InvalidServerResponse(sprintf('GeoIPs error %s%s%s%s - query: %s', $json['error']['code'], isset($json['error']['status']) ? ', '.$json['error']['status'] : '', isset($json['error']['message']) ? ', '.$json['error']['message'] : '', isset($json['error']['notes']) ? ', '.$json['error']['notes'] : '', $url));
148141
}
149142
}
150143

@@ -162,11 +155,7 @@ private function executeQuery(string $url): AddressCollection
162155
case static::CODE_NOT_FOUND:
163156
return new AddressCollection([]);
164157
default:
165-
throw new InvalidServerResponse(sprintf(
166-
'The GeoIPs API returned unknown result code "%s" for query: "%s".',
167-
$response['code'],
168-
$url
169-
));
158+
throw new InvalidServerResponse(sprintf('The GeoIPs API returned unknown result code "%s" for query: "%s".', $response['code'], $url));
170159
}
171160

172161
// Make sure that we do have proper result array

src/Provider/GoogleMaps/GoogleMaps.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,7 @@ private function validateResponse(string $url, $content)
437437
}
438438

439439
if ('REQUEST_DENIED' === $json->status) {
440-
throw new InvalidServerResponse(
441-
sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message)
442-
);
440+
throw new InvalidServerResponse(sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message));
443441
}
444442

445443
// you are over your quota

src/Provider/GoogleMapsPlaces/GoogleMapsPlaces.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,7 @@ private function validateResponse(string $url, $content): StdClass
392392
}
393393

394394
if ('REQUEST_DENIED' === $json->status) {
395-
throw new InvalidServerResponse(
396-
sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_messages)
397-
);
395+
throw new InvalidServerResponse(sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_messages));
398396
}
399397

400398
if ('OVER_QUERY_LIMIT' === $json->status) {

src/Provider/IP2LocationBinary/IP2LocationBinary.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ final class IP2LocationBinary extends AbstractProvider implements Provider
4545
public function __construct(string $binFile, int $openFlag = null)
4646
{
4747
if (false === class_exists('\\IP2Location\\Database')) {
48-
throw new FunctionNotFound(
49-
'ip2location_database',
50-
'The IP2LocationBinary requires IP2Location\'s library to be installed and loaded.'
51-
);
48+
throw new FunctionNotFound('ip2location_database', 'The IP2LocationBinary requires IP2Location\'s library to be installed and loaded.');
5249
}
5350

5451
if (false === is_file($binFile)) {

src/Provider/IpInfoDb/IpInfoDb.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ public function __construct(HttpClient $client, string $apiKey, string $precisio
7373
break;
7474

7575
default:
76-
throw new InvalidArgument(sprintf(
77-
'Invalid precision value "%s" (allowed values: "city", "country").',
78-
$precision
79-
));
76+
throw new InvalidArgument(sprintf('Invalid precision value "%s" (allowed values: "city", "country").', $precision));
8077
}
8178
}
8279

0 commit comments

Comments
 (0)