Completed
Push — master ( 2ffd30...269048 )
by Tobias
49:35 queued 27:06
created

IpInfoFactory::getProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
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\IpInfo\IpInfo;
16
use Geocoder\Provider\Provider;
17
use Http\Client\HttpClient;
18
use Http\Discovery\HttpClientDiscovery;
19
use Symfony\Component\OptionsResolver\OptionsResolver;
20
21 View Code Duplication
final class IpInfoFactory extends AbstractFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    protected static $dependencies = [
24
        ['requiredClass' => IpInfo::class, 'packageName' => 'geocoder-php/ip-info-provider'],
25
    ];
26
27 1
    protected function getProvider(array $config): Provider
28
    {
29 1
        $httplug = $config['httplug_client'] ?: HttpClientDiscovery::find();
30
31 1
        return new IpInfo($httplug);
32
    }
33
34 1
    protected static function configureOptionResolver(OptionsResolver $resolver)
35
    {
36 1
        $resolver->setDefaults([
37 1
            'httplug_client' => null,
38
        ]);
39
40 1
        $resolver->setAllowedTypes('httplug_client', [HttpClient::class, 'null']);
41 1
    }
42
}
43