@@ 18-43 (lines=26) @@ | ||
15 | use Http\Discovery\HttpClientDiscovery; |
|
16 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
17 | ||
18 | final class IpInfoDbFactory extends AbstractFactory |
|
19 | { |
|
20 | protected static $dependencies = [ |
|
21 | ['requiredClass' => IpInfoDb::class, 'packageName' => 'geocoder-php/ip-info-db-provider'], |
|
22 | ]; |
|
23 | ||
24 | protected function getProvider(array $config) |
|
25 | { |
|
26 | $httplug = $config['httplug_client'] ?: HttpClientDiscovery::find(); |
|
27 | ||
28 | return new IpInfoDb($httplug, $config['api_key'], $config['precision']); |
|
29 | } |
|
30 | ||
31 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
32 | { |
|
33 | $resolver->setDefaults([ |
|
34 | 'httplug_client' => null, |
|
35 | 'precision' => 'city', |
|
36 | ]); |
|
37 | ||
38 | $resolver->setRequired('api_key'); |
|
39 | $resolver->setAllowedTypes('httplug_client', [HttpClient::class, 'null']); |
|
40 | $resolver->setAllowedTypes('api_key', ['string']); |
|
41 | $resolver->setAllowedTypes('precision', ['string']); |
|
42 | } |
|
43 | } |
|
44 |
@@ 18-43 (lines=26) @@ | ||
15 | use Http\Discovery\HttpClientDiscovery; |
|
16 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
17 | ||
18 | final class MapQuestFactory extends AbstractFactory |
|
19 | { |
|
20 | protected static $dependencies = [ |
|
21 | ['requiredClass' => MapQuest::class, 'packageName' => 'geocoder-php/mapquest-provider'], |
|
22 | ]; |
|
23 | ||
24 | protected function getProvider(array $config) |
|
25 | { |
|
26 | $httplug = $config['httplug_client'] ?: HttpClientDiscovery::find(); |
|
27 | ||
28 | return new MapQuest($httplug, $config['api_key'], $config['licensed']); |
|
29 | } |
|
30 | ||
31 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
32 | { |
|
33 | $resolver->setDefaults([ |
|
34 | 'httplug_client' => null, |
|
35 | 'licensed' => false, |
|
36 | ]); |
|
37 | ||
38 | $resolver->setRequired('api_key'); |
|
39 | $resolver->setAllowedTypes('httplug_client', [HttpClient::class, 'null']); |
|
40 | $resolver->setAllowedTypes('api_key', ['string']); |
|
41 | $resolver->setAllowedTypes('licensed', ['boolean']); |
|
42 | } |
|
43 | } |
|
44 |