TacticianBundle   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 10
dl 0
loc 36
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A build() 0 8 1
A getContainerExtension() 0 4 1
A defaultMappingStrategy() 0 4 1
1
<?php
2
3
namespace League\Tactician\Bundle;
4
5
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\ClassNameMapping;
6
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\CompositeMapping;
7
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\HandlerMapping;
8
use League\Tactician\Bundle\DependencyInjection\HandlerMapping\TypeHintMapping;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use League\Tactician\Bundle\DependencyInjection\Compiler;
11
use League\Tactician\Bundle\DependencyInjection\TacticianExtension;
12
use Symfony\Component\HttpKernel\Bundle\Bundle;
13
14
class TacticianBundle extends Bundle
15
{
16
    /**
17
     * @var HandlerMapping
18
     */
19
    private $handlerMapping;
20
21 63
    public function __construct(HandlerMapping $handlerMapping = null)
22
    {
23 63
        if ($handlerMapping === null) {
24 63
            $handlerMapping = static::defaultMappingStrategy();
25
        }
26
27 63
        $this->handlerMapping = $handlerMapping;
28 63
    }
29
30
31 63
    public function build(ContainerBuilder $container)
32
    {
33 63
        parent::build($container);
34 63
        $container->addCompilerPass(new Compiler\DoctrineMiddlewarePass());
35 63
        $container->addCompilerPass(new Compiler\ValidatorMiddlewarePass());
36 63
        $container->addCompilerPass(new Compiler\SecurityMiddlewarePass());
37 63
        $container->addCompilerPass(new Compiler\CommandHandlerPass($this->handlerMapping));
38 63
    }
39
40 63
    public function getContainerExtension()
41
    {
42 63
        return new TacticianExtension();
43
    }
44
45 63
    public static function defaultMappingStrategy(): HandlerMapping
46
    {
47 63
        return new CompositeMapping(new TypeHintMapping(), new ClassNameMapping());
48
    }
49
}
50