| @@ 24-42 (lines=19) @@ | ||
| 21 | * |
|
| 22 | * @author Bernhard Schussek <[email protected]> |
|
| 23 | */ |
|
| 24 | class CannotAddOptionException extends RuntimeException |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Creates an exception for a duplicate option. |
|
| 28 | * |
|
| 29 | * @param string $name The option name. |
|
| 30 | * @param Exception $cause The exception that caused this exception. |
|
| 31 | * |
|
| 32 | * @return static The created exception. |
|
| 33 | */ |
|
| 34 | public static function existsAlready($name, Exception $cause = null) |
|
| 35 | { |
|
| 36 | return new static(sprintf( |
|
| 37 | 'An option named "%s%s" exists already.', |
|
| 38 | strlen($name) > 1 ? '--' : '-', |
|
| 39 | $name |
|
| 40 | ), 0, $cause); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 24-43 (lines=20) @@ | ||
| 21 | * |
|
| 22 | * @author Bernhard Schussek <[email protected]> |
|
| 23 | */ |
|
| 24 | class NoSuchOptionException extends RuntimeException |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Creates an exception for the given option name. |
|
| 28 | * |
|
| 29 | * @param string $name The option name. |
|
| 30 | * @param int $code The exception code. |
|
| 31 | * @param Exception $cause The exception that caused this exception. |
|
| 32 | * |
|
| 33 | * @return static The created exception. |
|
| 34 | */ |
|
| 35 | public static function forOptionName($name, $code = 0, Exception $cause = null) |
|
| 36 | { |
|
| 37 | return new static(sprintf( |
|
| 38 | 'The option "%s%s" does not exist.', |
|
| 39 | strlen($name) > 1 ? '--' : '-', |
|
| 40 | $name |
|
| 41 | ), $code, $cause); |
|
| 42 | } |
|
| 43 | } |
|
| 44 | ||