MaxMindBinaryFactory::configureOptionResolver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
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\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