Skip to content

Commit 71da9b7

Browse files
committed
style: fix readability of buildLayerFilterQuery
1 parent 02ede6b commit 71da9b7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/Provider/Photon/Photon.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,23 @@ public function getName(): string
177177
return 'photon';
178178
}
179179

180+
/**
181+
* @param string|string[]|null $layers
182+
*/
180183
private function buildLayerFilterQuery(mixed $layers): string
181184
{
182-
if (!is_iterable($layers)) {
183-
$layers = [$layers];
185+
$query = '';
186+
if (null === $layers) {
187+
return $query;
184188
}
185-
186-
if (!is_array($layers)) {
187-
$layers = iterator_to_array($layers);
189+
if (is_string($layers)) {
190+
return '&layer='.urlencode($layers);
191+
}
192+
foreach ($layers as $layer) {
193+
$query .= '&layer='.urlencode($layer);
188194
}
189195

190-
return implode('', array_map(
191-
static fn ($layer) => sprintf('&layer=%s', $layer),
192-
array_filter($layers, static fn ($layer) => is_scalar($layer)),
193-
));
196+
return $query;
194197
}
195198

196199
/**

0 commit comments

Comments
 (0)