Completed
Push — master ( 66cac0...4186cd )
by Tomas
11:25
created

HereFactory::configureOptionResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the BazingaGeocoderBundle package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Bazinga\GeocoderBundle\ProviderFactory;
14
15
use Geocoder\Provider\Here\Here;
16
use Geocoder\Provider\Provider;
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 1
    protected function getProvider(array $config): Provider
27
    {
28 1
        $httplug = $config['httplug_client'] ?: HttpClientDiscovery::find();
29
30 1
        return new Here($httplug, $config['app_id'], $config['app_code'], $config['use_cit']);
31
    }
32
33 1
    protected static function configureOptionResolver(OptionsResolver $resolver)
34
    {
35 1
        $resolver->setDefaults([
36 1
            'httplug_client' => null,
37
            'use_cit' => false,
38
        ]);
39
40 1
        $resolver->setAllowedTypes('httplug_client', ['object', 'null']);
41 1
        $resolver->setAllowedTypes('use_cit', ['bool', 'false']);
42 1
        $resolver->setRequired(['app_id', 'app_code']);
43 1
    }
44
}
45