Completed
Push — master ( 145693...9a5594 )
by Peter
06:17
created

GpsLabGeoIP2Extension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 21
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 18 3
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2017, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\GeoIP2Bundle\DependencyInjection;
11
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\Config\FileLocator;
14
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
15
use Symfony\Component\DependencyInjection\Loader;
16
17
class GpsLabGeoIP2Extension extends Extension
18
{
19
    public function load(array $configs, ContainerBuilder $container)
20
    {
21
        $config = $this->processConfiguration(new Configuration(), $configs);
22
23
        if (empty($config['cache'])) {
24
            $config['cache'] = $container->getParameter('kernel.cache_dir').'GeoLite2-Country.mmdb';
25
        }
26
27
        if (empty($config['url'])) {
28
            $config['url'] = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz';
29
        }
30
31
        $container->setParameter('geoip2.cache', $config['cache']);
32
        $container->setParameter('geoip2.url', $config['url']);
33
34
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
35
        $loader->load('services.yml');
36
    }
37
}
38