Completed
Push — master ( cda5b1...d40a3f )
by Ross
02:15
created

CanNotDetermineCommandNameException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forCommand() 9 9 2
A getCommand() 4 4 1

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 League\Tactician\Exception;
4
5
/**
6
 * Thrown when a CommandNameExtractor cannot determine the command's name
7
 */
8 View Code Duplication
class CanNotDetermineCommandNameException extends \RuntimeException implements Exception
0 ignored issues
show
Duplication introduced by
This class 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...
9
{
10
    /**
11
     * @var mixed
12
     */
13
    private $command;
14
15
    /**
16
     * @param mixed $command
17
     *
18
     * @return static
19
     */
20 11
    public static function forCommand($command)
21
    {
22 11
        $type =  is_object($command) ? get_class($command) : gettype($command);
23
24 11
        $exception = new static('Could not determine command name of ' . $type);
25 11
        $exception->command = $command;
26
27 11
        return $exception;
28
    }
29
30
    /**
31
     * Returns the command that could not be invoked
32
     *
33
     * @return mixed
34
     */
35 10
    public function getCommand()
36
    {
37 10
        return $this->command;
38
    }
39
}
40