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

GpsLabDateBundle::getContainerExtension()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 8.8571
c 2
b 0
f 0
cc 5
eloc 9
nc 8
nop 0
crap 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