1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* ~~summary~~ |
5
|
|
|
* |
6
|
|
|
* ~~description~~ |
7
|
|
|
* |
8
|
|
|
* PHP version 5 |
9
|
|
|
* |
10
|
|
|
* @category Net |
11
|
|
|
* @package PEAR2_Net_RouterOS |
12
|
|
|
* @author Vasil Rangelov <[email protected]> |
13
|
|
|
* @copyright 2011 Vasil Rangelov |
14
|
|
|
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 |
15
|
|
|
* @version GIT: $Id$ |
16
|
|
|
* @link http://pear2.php.net/PEAR2_Net_RouterOS |
17
|
|
|
*/ |
18
|
|
|
/** |
19
|
|
|
* The namespace declaration. |
20
|
|
|
*/ |
21
|
|
|
namespace PEAR2\Net\RouterOS; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The base for this exception. |
25
|
|
|
*/ |
26
|
|
|
use UnexpectedValueException as U; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Used in $previous. |
30
|
|
|
*/ |
31
|
|
|
use Exception as E; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Exception thrown when encountering an invalid value in a function argument. |
35
|
|
|
* |
36
|
|
|
* @category Net |
37
|
|
|
* @package PEAR2_Net_RouterOS |
38
|
|
|
* @author Vasil Rangelov <[email protected]> |
39
|
|
|
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 |
40
|
|
|
* @link http://pear2.php.net/PEAR2_Net_RouterOS |
41
|
|
|
*/ |
42
|
|
|
class UnexpectedValueException extends U implements Exception |
43
|
|
|
{ |
44
|
|
|
const CODE_CALLBACK_INVALID = 10502; |
45
|
|
|
const CODE_ACTION_UNKNOWN = 30100; |
46
|
|
|
const CODE_RESPONSE_TYPE_UNKNOWN = 50100; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The unexpected value. |
50
|
|
|
* |
51
|
|
|
* @var mixed |
52
|
|
|
*/ |
53
|
|
|
private $_value; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Creates a new UnexpectedValueException. |
57
|
|
|
* |
58
|
|
|
* @param string $message The Exception message to throw. |
59
|
|
|
* @param int $code The Exception code. |
60
|
|
|
* @param E|null $previous The previous exception used for the exception |
61
|
|
|
* chaining. |
62
|
|
|
* @param mixed $value The unexpected value. |
63
|
|
|
*/ |
64
|
|
|
public function __construct( |
65
|
|
|
$message, |
66
|
|
|
$code = 0, |
67
|
|
|
E $previous = null, |
68
|
|
|
$value = null |
69
|
|
|
) { |
70
|
|
|
parent::__construct($message, $code, $previous); |
71
|
|
|
$this->_value = $value; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Gets the unexpected value. |
76
|
|
|
* |
77
|
|
|
* @return mixed The unexpected value. |
78
|
|
|
*/ |
79
|
|
|
public function getValue() |
80
|
|
|
{ |
81
|
|
|
return $this->_value; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
// @codeCoverageIgnoreStart |
85
|
|
|
// String representation is not reliable in testing |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns a string representation of the exception. |
89
|
|
|
* |
90
|
|
|
* @return string The exception as a string. |
91
|
|
|
*/ |
92
|
|
|
public function __toString() |
93
|
|
|
{ |
94
|
|
|
return parent::__toString() . "\nValue:{$this->_value}"; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
// @codeCoverageIgnoreEnd |
98
|
|
|
} |
99
|
|
|
|