HereFactory::getProvider()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
3
namespace DH\NavigationBundle\Provider\Here;
4
5
use DH\NavigationBundle\Provider\AbstractFactory;
6
use DH\NavigationBundle\Provider\ProviderInterface;
7
use GuzzleHttp\Client;
8
use Symfony\Component\OptionsResolver\OptionsResolver;
9
10
final class HereFactory extends AbstractFactory
11
{
12
    protected function getProvider(array $config): ProviderInterface
13
    {
14
        $client = $config['http_client'] ?: new Client();
15
16
        return new Here($client, $config['app_id'], $config['app_code'], $config['use_cit']);
17
    }
18
19
    protected static function configureOptionResolver(OptionsResolver $resolver): void
20
    {
21
        $resolver->setDefaults([
22
            'http_client' => null,
23
            'app_id' => null,
24
            'app_code' => null,
25
            'use_cit' => false,
26
        ]);
27
28
        $resolver->setAllowedTypes('http_client', ['object', 'null']);
29
        $resolver->setAllowedTypes('app_id', ['string', 'null']);
30
        $resolver->setAllowedTypes('app_code', ['string', 'null']);
31
        $resolver->setRequired(['app_id', 'app_code']);
32
    }
33
}
34