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

GpsLabDateBundle::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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