CanNotDetermineCommandNameException::getCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 Sági-Kazár Márk
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