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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addHandler() 0 6 1
A getHandlerForCommand() 0 11 2
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