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