LoopBackApiBundle   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 2 Features 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 3
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getContainerExtension() 0 23 5
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