GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 6fc5c2...bd52da )
by Andrey
12:38
created

CommandBus   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 54
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addMiddleware() 0 4 1
A handle() 0 9 2
1
<?php
2
3
/**
4
 * (c) itmedia.by <[email protected]>
5
 */
6
7
namespace Itmedia\CommandBusBundle\CommandBus;
8
9
use Itmedia\CommandBusBundle\Command\Command;
10
use Itmedia\CommandBusBundle\Handler\ContainerCommandHandlerMapper;
11
use Itmedia\CommandBusBundle\Middleware\Middleware;
12
13
class CommandBus
14
{
15
16
    /**
17
     * @var ContainerCommandHandlerMapper
18
     */
19
    private $handlerMapper;
20
21
    /**
22
     * @var Middleware[]
23
     */
24
    private $middleware = [];
25
26
27
    /**
28
     * CommandBus constructor.
29
     *
30
     * @param ContainerCommandHandlerMapper $handlerMapper
31
     */
32
    public function __construct(ContainerCommandHandlerMapper $handlerMapper)
33
    {
34
        $this->handlerMapper = $handlerMapper;
35
    }
36
37
38
    /**
39
     * Добавить доп. обработчик команды (Middleware)
40
     *
41
     * @param Middleware $middleware
42
     */
43
    public function addMiddleware(Middleware $middleware)
44
    {
45
        $this->middleware[] = $middleware;
46
    }
47
48
49
    /**
50
     * Handle command
51
     *
52
     * @param Command $command
53
     * @throws \Itmedia\CommandBusBundle\Exception\HandlerNotFoundException
54
     * @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
55
     * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
56
     */
57
    public function handle(Command $command)
58
    {
59
        foreach ($this->middleware as $middleware) {
60
            $middleware->handle($command);
61
        }
62
63
        $handler = $this->handlerMapper->get($command->commandName());
64
        call_user_func($handler, $command);
65
    }
66
}
67