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.

LaravelLazyLocator::addHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Joselfonseca\LaravelTactician\Locator;
4
5
use League\Tactician\Exception\MissingHandlerException;
6
7
class LaravelLazyLocator extends LaravelLocator
8
{
9
10
    /**
11
     * Bind a handler instance to receive all commands with a certain class
12
     *
13
     * @param string $handler          Handler to receive class name
14
     * @param string $commandClassName Command class e.g. "My\TaskAddedCommand"
15
     */
16 11
    public function addHandler($handler, $commandClassName)
17
    {
18
        $this->handlers[$commandClassName] = function () use ($handler) {
19 10
            return app($handler);
20
        };
21 11
    }
22
23
    /**
24
     * Retrieves the handler for a specified command
25
     *
26
     * @param string $commandName
27
     *
28
     * @return object
29
     *
30
     * @throws MissingHandlerException
31
     */
32 12
    public function getHandlerForCommand($commandName)
33
    {
34 12
        if (!is_callable($this->handlers[$commandName])) {
35 2
            throw MissingHandlerException::forCommand($commandName);
36
        }
37
38
        /** @var callable $handler */
39 10
        $handler = $this->handlers[$commandName];
40
41 10
        return $handler();
42
    }
43
}
44