Completed
Push — master ( 765a87...b5032e )
by Peter
04:25
created

GpsLabDateBundle   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 32
ccs 16
cts 16
cp 1
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 5 1
B getContainerExtension() 0 17 5
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\DateBundle;
11
12
use GpsLab\Bundle\DateBundle\DependencyInjection\Compiler\TimeZoneResolverPass;
13
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
14
use Symfony\Component\HttpKernel\Bundle\Bundle;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
class GpsLabDateBundle extends Bundle
18
{
19
    /**
20
     * @param ContainerBuilder $container
21
     */
22 1
    public function build(ContainerBuilder $container)
23
    {
24 1
        parent::build($container);
25 1
        $container->addCompilerPass(new TimeZoneResolverPass());
26 1
    }
27
28
    /**
29
     * @return ExtensionInterface|null
30
     */
31 1
    public function getContainerExtension()
32
    {
33 1
        if (null === $this->extension) {
34 1
            $this->extension = false;
35 1
            $class = $this->getContainerExtensionClass();
36
37 1
            if (class_exists($class)) {
38 1
                $extension = new $class();
39
40 1
                if ($extension instanceof ExtensionInterface) {
41 1
                    $this->extension = $extension;
42 1
                }
43 1
            }
44 1
        }
45
46 1
        return $this->extension ?: null;
47
    }
48
}
49