Code Duplication    Length = 32-36 lines in 2 locations

src/Exception/CanNotDetermineCommandNameException.php 1 location

@@ 10-41 (lines=32) @@
7
/**
8
 * Thrown when a CommandNameExtractor cannot determine the command's name
9
 */
10
class CanNotDetermineCommandNameException extends RuntimeException implements Exception
11
{
12
    /**
13
     * @var mixed
14
     */
15
    private $command;
16
17
    /**
18
     * @param mixed $command
19
     *
20
     * @return static
21
     */
22
    public static function forCommand($command)
23
    {
24
        $type =  is_object($command) ? get_class($command) : gettype($command);
25
26
        $exception = new static('Could not determine command name of ' . $type);
27
        $exception->command = $command;
28
29
        return $exception;
30
    }
31
32
    /**
33
     * Returns the command that could not be invoked
34
     *
35
     * @return mixed
36
     */
37
    public function getCommand()
38
    {
39
        return $this->command;
40
    }
41
}
42

src/Exception/CanNotInvokeHandlerException.php 1 location

@@ 13-48 (lines=36) @@
10
 * The most common reason is the receiving method is missing or incorrectly
11
 * named.
12
 */
13
class CanNotInvokeHandlerException extends BadMethodCallException implements Exception
14
{
15
    /**
16
     * @var mixed
17
     */
18
    private $command;
19
20
    /**
21
     * @param mixed $command
22
     * @param string $reason
23
     *
24
     * @return static
25
     */
26
    public static function forCommand($command, $reason)
27
    {
28
        $type =  is_object($command) ? get_class($command) : gettype($command);
29
30
        $exception = new static(
31
            'Could not invoke handler for command ' . $type .
32
            ' for reason: ' . $reason
33
        );
34
        $exception->command = $command;
35
36
        return $exception;
37
    }
38
39
    /**
40
     * Returns the command that could not be invoked
41
     *
42
     * @return mixed
43
     */
44
    public function getCommand()
45
    {
46
        return $this->command;
47
    }
48
}
49