Skip to content

Commit 404e5c3

Browse files
committed
chore: refactored some code
1 parent 391014e commit 404e5c3

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Config.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ class Config
1717

1818
public function __construct(array $options = [])
1919
{
20-
$resolver = new OptionsResolver();
21-
$this->configureOptions($resolver);
22-
$this->options = $resolver->resolve($options);
20+
$this->options = $this->resolveOptions($options);
2321
}
2422

25-
private function configureOptions(OptionsResolver $resolver): void
23+
private function resolveOptions(array $options): array
2624
{
25+
$resolver = new OptionsResolver();
26+
2727
$resolver->setDefaults([
2828
'unitSystem' => UnitSystem::METRIC,
2929
'language' => Language::ENGLISH,
@@ -46,6 +46,8 @@ private function configureOptions(OptionsResolver $resolver): void
4646
});
4747
$resolver->setAllowedValues('unitSystem', UnitSystem::getList());
4848
$resolver->setAllowedValues('language', Language::getList());
49+
50+
return $resolver->resolve($options);
4951
}
5052

5153
public function getApplicationKey(): string

src/Endpoint/AbstractEndpoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private function buildUrl(UriInterface|string $baseUrl, array $query): string
133133

134134
// Add application key to all requests
135135
$query = $query + [
136-
'appid' => $this->api->getConfig()->getApplicationKey()
136+
'appid' => $this->config->getApplicationKey()
137137
];
138138

139139
return \sprintf('%s?%s', $baseUrl, http_build_query($query));

0 commit comments

Comments
 (0)