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

MaxMindBinaryFactory::getProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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