ChainFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProvider() 0 9 2
A configureOptionResolver() 0 7 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