JKSamBundle::getContainerExtension()   A
last analyzed

Complexity

Conditions 5
Paths 7

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 0
Metric Value
cc 5
nc 7
nop 0
dl 0
loc 22
ccs 0
cts 19
cp 0
crap 30
rs 9.2568
c 0
b 0
f 0
1
<?php
2
3
namespace JK\SamBundle;
4
5
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
6
use Symfony\Component\HttpKernel\Bundle\Bundle;
7
8
class JKSamBundle extends Bundle
9
{
10
    /**
11
     * @return bool|ExtensionInterface
12
     */
13
    public function getContainerExtension()
14
    {
15
        if (null === $this->extension) {
16
            $class = $this->getContainerExtensionClass();
17
18
            if (class_exists($class)) {
19
                $extension = new $class();
20
21
                if (!$extension instanceof ExtensionInterface) {
22
                    throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', $class));
23
                }
24
                $this->extension = $extension;
25
            } else {
26
                $this->extension = false;
27
            }
28
        }
29
        if ($this->extension) {
30
            return $this->extension;
31
        }
32
        
33
        return null;
34
    }
35
}
36