MaxMindBinaryFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProvider() 0 4 1
A configureOptionResolver() 0 10 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\MaxMindBinary\MaxMindBinary;
16
use Geocoder\Provider\Provider;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
19
final class MaxMindBinaryFactory extends AbstractFactory
20
{
21
    protected static $dependencies = [
22
        ['requiredClass' => MaxMindBinary::class, 'packageName' => 'geocoder-php/maxmind-binary-provider'],
23
    ];
24
25 1
    protected function getProvider(array $config): Provider
26
    {
27 1
        return new MaxMindBinary($config['dat_file'], $config['open_flag']);
28
    }
29
30 1
    protected static function configureOptionResolver(OptionsResolver $resolver)
31
    {
32 1
        $resolver->setDefaults([
33 1
            'open_flag' => null,
34
        ]);
35
36 1
        $resolver->setRequired('dat_file');
37 1
        $resolver->setAllowedTypes('dat_file', ['string']);
38 1
        $resolver->setAllowedTypes('open_flag', ['string', 'null']);
39 1
    }
40
}
41