Completed
Push — master ( e761a5...0fd153 )
by Tobias
09:58 queued 02:02
created

MaxMindBinaryFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 22
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
/*
4
 * This file is part of the BazingaGeocoderBundle package.
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @license    MIT License
9
 */
10
11
namespace Bazinga\GeocoderBundle\ProviderFactory;
12
13
use Geocoder\Provider\MaxMind\MaxMind;
14
use Geocoder\Provider\MaxMindBinary\MaxMindBinary;
15
use Symfony\Component\OptionsResolver\OptionsResolver;
16
17
final class MaxMindBinaryFactory extends AbstractFactory
18
{
19
    protected static $dependencies = [
20
        ['requiredClass' => MaxMindBinary::class, 'packageName' => 'geocoder-php/maxmind-binary-provider'],
21
    ];
22
23
    protected function getProvider(array $config)
24
    {
25
        return new MaxMindBinary($config['dat_file'], $config['open_flag']);
26
    }
27
28
    protected static function configureOptionResolver(OptionsResolver $resolver)
29
    {
30
        $resolver->setDefaults([
31
            'open_flag' => null,
32
        ]);
33
34
        $resolver->setRequired('dat_file');
35
        $resolver->setAllowedTypes('dat_file', ['string']);
36
        $resolver->setAllowedTypes('open_flag', ['string', 'null']);
37
    }
38
}
39