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

ContainerCommandHandlerMapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get() 0 18 3
1
<?php
2
3
/**
4
 * (c) itmedia.by <[email protected]>
5
 */
6
7
namespace Itmedia\CommandBusBundle\Handler;
8
9
use Itmedia\CommandBusBundle\Exception\HandlerNotFoundException;
10
use Symfony\Component\DependencyInjection\ContainerInterface;
11
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
12
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
13
14
class ContainerCommandHandlerMapper implements CommandHandlerMapper
15
{
16
    /**
17
     * Карта методов вызова
18
     * [messageName => [service => '...', 'method' => '...']]
19
     *
20
     * @var array
21
     */
22
    private $callableMap = [];
23
24
    /**
25
     * @var ContainerInterface
26
     */
27
    private $container;
28
29
    /**
30
     * HandlerMapper constructor.
31
     *
32
     * @param ContainerInterface $container
33
     * @param array $callableMap
34
     */
35
    public function __construct(ContainerInterface $container, array $callableMap)
36
    {
37
        $this->container = $container;
38
        $this->callableMap = $callableMap;
39
    }
40
41
42
    /**
43
     * @param $commandName
44
     *
45
     * @return callable
46
     * @throws HandlerNotFoundException|ServiceNotFoundException|ServiceCircularReferenceException
47
     */
48
    public function get($commandName)
49
    {
50
        if (!array_key_exists($commandName, $this->callableMap)) {
51
            throw new HandlerNotFoundException(sprintf(
52
                'Could not find a handler for name "%s"',
53
                $commandName
54
            ));
55
        }
56
57
        $callable = $this->callableMap[$commandName];
58
59
        $methodName = $callable['method'] ?: 'execute';
60
61
        return [
62
            $this->container->get($callable['service']),
63
            $methodName
64
        ];
65
    }
66
}
67