These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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 |
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.