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.
Completed
Pull Request — master (#6)
by Koldo
02:33
created

LaravelLazyLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 23.53 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addHandler() 0 6 1
A getHandlerForCommand() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
    public function addHandler($handler, $commandClassName)
17
    {
18
        $this->handlers[$commandClassName] = function () use ($handler) {
19
            return app($handler);
20
        };
21
    }
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 View Code Duplication
    public function getHandlerForCommand($commandName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        if (!isset($this->handlers[$commandName])) {
35
            throw MissingHandlerException::forCommand($commandName);
36
        }
37
38
        return $this->handlers[$commandName]();
39
    }
40
}
41