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.

LaravelLocator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 57
ccs 6
cts 12
cp 0.5
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addHandlers() 0 6 2
A addHandler() 0 5 1
A getHandlerForCommand() 0 8 2
1
<?php
2
3
namespace Joselfonseca\LaravelTactician\Locator;
4
5
use League\Tactician\Exception\MissingHandlerException;
6
7
/**
8
 * Class LaravelLocator
9
 *
10
 * @package Joselfonseca\LaravelTactician\Locator
11
 */
12
class LaravelLocator implements LocatorInterface
13
{
14
15
    /**
16
     * The handlers
17
     * @var
18
     */
19
    protected $handlers;
20
21
    /**
22
     * Bind a handler instance to receive all commands with a certain class
23
     *
24
     * @param string $handler          Handler to receive class name
25
     * @param string $commandClassName Command class e.g. "My\TaskAddedCommand"
26
     */
27 1
    public function addHandler($handler, $commandClassName)
28
    {
29 1
        $handlerInstance = app($handler);
30
        $this->handlers[$commandClassName] = $handlerInstance;
31
    }
32
33
    /**
34
     * Allows you to add multiple handlers at once.
35
     *
36
     * The map should be an array in the format of:
37
     *  [
38
     *      AddTaskCommand::class      => $someHandlerClassName,
39
     *      CompleteTaskCommand::class => $someHandlerClassName,
40
     *  ]
41
     *
42
     * @param array $commandClassToHandlerMap
43
     */
44 2
    public function addHandlers(array $commandClassToHandlerMap)
45
    {
46 2
        foreach ($commandClassToHandlerMap as $commandClass => $handler) {
47 2
            $this->addHandler($handler, $commandClass);
48
        }
49 2
    }
50
51
    /**
52
     * Retrieves the handler for a specified command
53
     *
54
     * @param string $commandName
55
     *
56
     * @return object
57
     *
58
     * @throws MissingHandlerException
59
     */
60
    public function getHandlerForCommand($commandName)
61
    {
62
        if (!isset($this->handlers[$commandName])) {
63
            throw MissingHandlerException::forCommand($commandName);
64
        }
65
66
        return $this->handlers[$commandName];
67
    }
68
}
69