TacticianProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 45
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDefinitions() 0 17 1
1
<?php
2
3
namespace Mosaic\CommandBus\Providers;
4
5
use Interop\Container\Definition\DefinitionProviderInterface;
6
use League\Tactician\Handler\CommandHandlerMiddleware;
7
use League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor;
8
use League\Tactician\Handler\MethodNameInflector\HandleInflector;
9
use Mosaic\CommandBus\Adapters\Tactician\HandlerLocator;
10
use Mosaic\CommandBus\Adapters\Tactician\TacticianBus;
11
use Mosaic\CommandBus\CommandBus;
12
use Mosaic\Container\Container;
13
14
class TacticianProvider implements DefinitionProviderInterface
15
{
16
    /**
17
     * @var Container
18
     */
19
    private $container;
20
21
    /**
22
     * @param Container $container
23
     */
24 1
    public function __construct(Container $container)
25
    {
26 1
        $this->container = $container;
27 1
    }
28
29
    /**
30
     * Returns the definition to register in the container.
31
     *
32
     * Definitions must be indexed by their entry ID. For example:
33
     *
34
     *     return [
35
     *         'logger' => ...
36
     *         'mailer' => ...
37
     *     ];
38
     *
39
     * @return array
40
     */
41
    public function getDefinitions()
42
    {
43
        return [
44 1
            CommandBus::class => function () {
45
                return new TacticianBus(
46
                    $this->container,
47
                    [
48
                        new CommandHandlerMiddleware(
49
                            new ClassNameExtractor(),
50
                            new HandlerLocator($this->container),
51
                            new HandleInflector()
52
                        )
53
                    ]
54
                );
55 1
            }
56
        ];
57
    }
58
}
59