ChainFactory::configureOptionResolver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
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\Chain\Chain;
16
use Geocoder\Provider\Provider;
17
use Psr\Log\LoggerAwareInterface;
18
use Psr\Log\LoggerAwareTrait;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21
/**
22
 * @author Tobias Nyholm <[email protected]>
23
 */
24
final class ChainFactory extends AbstractFactory implements LoggerAwareInterface
25
{
26
    use LoggerAwareTrait;
27
28
    protected static $dependencies = [
29
        ['requiredClass' => Chain::class, 'packageName' => 'geocoder-php/chain-provider'],
30
    ];
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 1
    protected function getProvider(array $config): Provider
36
    {
37 1
        $provider = new Chain($config['services']);
38 1
        if (null !== $this->logger) {
39 1
            $provider->setLogger($this->logger);
40
        }
41
42 1
        return $provider;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 1
    protected static function configureOptionResolver(OptionsResolver $resolver)
49
    {
50 1
        parent::configureOptionResolver($resolver);
51
52 1
        $resolver->setRequired('services');
53 1
        $resolver->setAllowedTypes('services', ['array']);
54 1
    }
55
}
56