LoopBackApiBundle::getContainerExtension()   B
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
dl 0
loc 23
rs 8.5906
c 2
b 2
f 0
cc 5
eloc 13
nc 7
nop 0
1
<?php
2
3
/*
4
 * This file is part of the LoopBackApiBundle package.
5
 *
6
 * (c) Théo FIDRY <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Fidry\LoopBackApiBundle;
13
14
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
15
use Symfony\Component\HttpKernel\Bundle\Bundle;
16
17
/**
18
 * LoopBackApiBundle.
19
 *
20
 * @author Théo FIDRY <[email protected]>
21
 */
22
class LoopBackApiBundle extends Bundle
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function getContainerExtension()
28
    {
29
        if (null === $this->extension) {
30
            $class = $this->getContainerExtensionClass();
31
            if (class_exists($class)) {
32
                $extension = new $class();
33
34
                if (!$extension instanceof ExtensionInterface) {
35
                    throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class));
36
                }
37
38
                $this->extension = $extension;
39
            } else {
40
                $this->extension = false;
41
            }
42
        }
43
44
        if ($this->extension) {
45
            return $this->extension;
46
        }
47
48
        return null;
49
    }
50
}
51