@@ 20-41 (lines=22) @@ | ||
17 | use Http\Discovery\HttpClientDiscovery; |
|
18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
19 | ||
20 | final class GeoPluginFactory extends AbstractFactory |
|
21 | { |
|
22 | protected static $dependencies = [ |
|
23 | ['requiredClass' => GeoPlugin::class, 'packageName' => 'geocoder-php/geo-plugin-provider'], |
|
24 | ]; |
|
25 | ||
26 | protected function getProvider(array $config): Provider |
|
27 | { |
|
28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
29 | ||
30 | return new GeoPlugin($httplug); |
|
31 | } |
|
32 | ||
33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
34 | { |
|
35 | $resolver->setDefaults([ |
|
36 | 'httplug_client' => null, |
|
37 | ]); |
|
38 | ||
39 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
40 | } |
|
41 | } |
|
42 |
@@ 20-41 (lines=22) @@ | ||
17 | use Http\Discovery\HttpClientDiscovery; |
|
18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
19 | ||
20 | final class HostIpFactory extends AbstractFactory |
|
21 | { |
|
22 | protected static $dependencies = [ |
|
23 | ['requiredClass' => HostIp::class, 'packageName' => 'geocoder-php/host-ip-provider'], |
|
24 | ]; |
|
25 | ||
26 | protected function getProvider(array $config): Provider |
|
27 | { |
|
28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
29 | ||
30 | return new HostIp($httplug); |
|
31 | } |
|
32 | ||
33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
34 | { |
|
35 | $resolver->setDefaults([ |
|
36 | 'httplug_client' => null, |
|
37 | ]); |
|
38 | ||
39 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
40 | } |
|
41 | } |
|
42 |
@@ 20-41 (lines=22) @@ | ||
17 | use Http\Discovery\HttpClientDiscovery; |
|
18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
19 | ||
20 | final class IpInfoFactory extends AbstractFactory |
|
21 | { |
|
22 | protected static $dependencies = [ |
|
23 | ['requiredClass' => IpInfo::class, 'packageName' => 'geocoder-php/ip-info-provider'], |
|
24 | ]; |
|
25 | ||
26 | protected function getProvider(array $config): Provider |
|
27 | { |
|
28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
29 | ||
30 | return new IpInfo($httplug); |
|
31 | } |
|
32 | ||
33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
34 | { |
|
35 | $resolver->setDefaults([ |
|
36 | 'httplug_client' => null, |
|
37 | ]); |
|
38 | ||
39 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
40 | } |
|
41 | } |
|
42 |