Skip to content

Commit e514576

Browse files
committed
refactor(geocoding): simplify optional queries
1 parent a63bdde commit e514576

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

‎src/Resource/Geocoding.php‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ public function byName(string $name, ?int $limit = null): array
2222
$limit = Assert::integerBetween($limit, 1, 5, 'result limit');
2323
}
2424

25-
$query = ['q' => $name];
26-
27-
if ($limit !== null) {
28-
$query['limit'] = $limit;
29-
}
30-
3125
return $this
3226
->endpoint()
33-
->queries($query)
27+
->queries([
28+
'q' => $name,
29+
'limit' => $limit,
30+
])
3431
->get('/geo/1.0/direct')
3532
->collection(Location::class);
3633
}
@@ -74,18 +71,13 @@ public function byCoordinates(
7471
$limit = Assert::positiveInteger($limit, 'result limit');
7572
}
7673

77-
$query = [
78-
'lat' => $latitude,
79-
'lon' => $longitude,
80-
];
81-
82-
if ($limit !== null) {
83-
$query['limit'] = $limit;
84-
}
85-
8674
return $this
8775
->endpoint()
88-
->queries($query)
76+
->queries([
77+
'lat' => $latitude,
78+
'lon' => $longitude,
79+
'limit' => $limit,
80+
])
8981
->get('/geo/1.0/reverse')
9082
->collection(Location::class);
9183
}

0 commit comments

Comments
 (0)