| @@ 20-44 (lines=25) @@ | ||
| 17 | use Http\Discovery\HttpClientDiscovery; |
|
| 18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
| 19 | ||
| 20 | final class HereFactory extends AbstractFactory |
|
| 21 | { |
|
| 22 | protected static $dependencies = [ |
|
| 23 | ['requiredClass' => Here::class, 'packageName' => 'geocoder-php/here-provider'], |
|
| 24 | ]; |
|
| 25 | ||
| 26 | protected function getProvider(array $config): Provider |
|
| 27 | { |
|
| 28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
| 29 | ||
| 30 | return new Here($httplug, $config['app_id'], $config['app_code'], $config['use_cit']); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
| 34 | { |
|
| 35 | $resolver->setDefaults([ |
|
| 36 | 'httplug_client' => null, |
|
| 37 | 'use_cit' => false, |
|
| 38 | ]); |
|
| 39 | ||
| 40 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
| 41 | $resolver->setAllowedTypes('use_cit', ['bool', 'false']); |
|
| 42 | $resolver->setRequired(['app_id', 'app_code']); |
|
| 43 | } |
|
| 44 | } |
|
| 45 | ||
| @@ 20-45 (lines=26) @@ | ||
| 17 | use Http\Discovery\HttpClientDiscovery; |
|
| 18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
| 19 | ||
| 20 | final class IpInfoDbFactory extends AbstractFactory |
|
| 21 | { |
|
| 22 | protected static $dependencies = [ |
|
| 23 | ['requiredClass' => IpInfoDb::class, 'packageName' => 'geocoder-php/ip-info-db-provider'], |
|
| 24 | ]; |
|
| 25 | ||
| 26 | protected function getProvider(array $config): Provider |
|
| 27 | { |
|
| 28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
| 29 | ||
| 30 | return new IpInfoDb($httplug, $config['api_key'], $config['precision']); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
| 34 | { |
|
| 35 | $resolver->setDefaults([ |
|
| 36 | 'httplug_client' => null, |
|
| 37 | 'precision' => 'city', |
|
| 38 | ]); |
|
| 39 | ||
| 40 | $resolver->setRequired('api_key'); |
|
| 41 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
| 42 | $resolver->setAllowedTypes('api_key', ['string']); |
|
| 43 | $resolver->setAllowedTypes('precision', ['string']); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 20-45 (lines=26) @@ | ||
| 17 | use Http\Discovery\HttpClientDiscovery; |
|
| 18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
| 19 | ||
| 20 | final class MapQuestFactory extends AbstractFactory |
|
| 21 | { |
|
| 22 | protected static $dependencies = [ |
|
| 23 | ['requiredClass' => MapQuest::class, 'packageName' => 'geocoder-php/mapquest-provider'], |
|
| 24 | ]; |
|
| 25 | ||
| 26 | protected function getProvider(array $config): Provider |
|
| 27 | { |
|
| 28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
| 29 | ||
| 30 | return new MapQuest($httplug, $config['api_key'], $config['licensed']); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
| 34 | { |
|
| 35 | $resolver->setDefaults([ |
|
| 36 | 'httplug_client' => null, |
|
| 37 | 'licensed' => false, |
|
| 38 | ]); |
|
| 39 | ||
| 40 | $resolver->setRequired('api_key'); |
|
| 41 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
| 42 | $resolver->setAllowedTypes('api_key', ['string']); |
|
| 43 | $resolver->setAllowedTypes('licensed', ['boolean']); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 20-46 (lines=27) @@ | ||
| 17 | use Http\Discovery\HttpClientDiscovery; |
|
| 18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
|
| 19 | ||
| 20 | final class NominatimFactory extends AbstractFactory |
|
| 21 | { |
|
| 22 | protected static $dependencies = [ |
|
| 23 | ['requiredClass' => Nominatim::class, 'packageName' => 'geocoder-php/nominatim-provider'], |
|
| 24 | ]; |
|
| 25 | ||
| 26 | protected function getProvider(array $config): Provider |
|
| 27 | { |
|
| 28 | $httplug = $config['httplug_client'] ?: $this->httpClient ?? HttpClientDiscovery::find(); |
|
| 29 | ||
| 30 | return new Nominatim($httplug, $config['root_url'], $config['user_agent']); |
|
| 31 | } |
|
| 32 | ||
| 33 | protected static function configureOptionResolver(OptionsResolver $resolver) |
|
| 34 | { |
|
| 35 | $resolver->setDefaults([ |
|
| 36 | 'httplug_client' => null, |
|
| 37 | 'root_url' => 'https://nominatim.openstreetmap.org', |
|
| 38 | 'user_agent' => 'BazingaGeocoderBundle', |
|
| 39 | ]); |
|
| 40 | ||
| 41 | $resolver->setAllowedTypes('httplug_client', ['object', 'null']); |
|
| 42 | $resolver->setAllowedTypes('root_url', ['string']); |
|
| 43 | $resolver->setAllowedTypes('user_agent', ['string']); |
|
| 44 | $resolver->setRequired('user_agent'); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||