1 | <?php |
||
5 | class ValidationError implements \ArrayAccess |
||
6 | { |
||
7 | /** |
||
8 | * @var string |
||
9 | */ |
||
10 | private $message; |
||
11 | |||
12 | /** |
||
13 | * @var int |
||
14 | */ |
||
15 | private $code; |
||
16 | |||
17 | /** |
||
18 | * @var string|null |
||
19 | */ |
||
20 | private $pointer; |
||
21 | |||
22 | /** |
||
23 | * @var mixed |
||
24 | */ |
||
25 | private $value; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $constraints; |
||
31 | |||
32 | /** |
||
33 | * @param string $message |
||
34 | * @param int $code |
||
35 | * @param mixed $value |
||
36 | * @param string|null $pointer |
||
37 | * @param array $constraints |
||
38 | */ |
||
39 | 34 | public function __construct($message, $code, $value, $pointer = null, array $constraints = []) |
|
47 | |||
48 | /** |
||
49 | * Get the human readable error message for this error. |
||
50 | * |
||
51 | * @return string |
||
52 | */ |
||
53 | 4 | public function getMessage() |
|
57 | |||
58 | /** |
||
59 | * Get the error code for this error. |
||
60 | * |
||
61 | * @return int |
||
62 | */ |
||
63 | 4 | public function getCode() |
|
67 | |||
68 | /** |
||
69 | * Get the path to the property that failed validation. |
||
70 | * |
||
71 | * @return string|null |
||
72 | */ |
||
73 | 4 | public function getPointer() |
|
77 | |||
78 | /** |
||
79 | * Get the value that caused the assertion to fail. |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | 4 | public function getValue() |
|
87 | |||
88 | /** |
||
89 | * Get the constraints that applied to the failed assertion. |
||
90 | * |
||
91 | * @return array |
||
92 | */ |
||
93 | 4 | public function getConstraints() |
|
97 | |||
98 | /** |
||
99 | * @return array |
||
100 | */ |
||
101 | 4 | public function toArray() |
|
111 | |||
112 | /** |
||
113 | * Whether a offset exists |
||
114 | * @link http://php.net/manual/en/arrayaccess.offsetexists.php |
||
115 | * |
||
116 | * @param mixed $offset <p> |
||
117 | * An offset to check for. |
||
118 | * </p> |
||
119 | * |
||
120 | * @return boolean true on success or false on failure. |
||
121 | * </p> |
||
122 | * <p> |
||
123 | * The return value will be casted to boolean if non-boolean was returned. |
||
124 | * @since 5.0.0 |
||
125 | */ |
||
126 | 1 | public function offsetExists($offset) |
|
127 | { |
||
128 | 1 | return array_key_exists($offset, $this->toArray()); |
|
129 | } |
||
130 | |||
131 | /** |
||
132 | * Offset to retrieve |
||
133 | * @link http://php.net/manual/en/arrayaccess.offsetget.php |
||
134 | * |
||
135 | * @param mixed $offset <p> |
||
136 | * The offset to retrieve. |
||
137 | * </p> |
||
138 | * |
||
139 | * @return mixed Can return all value types. |
||
140 | * @since 5.0.0 |
||
141 | */ |
||
142 | 4 | public function offsetGet($offset) |
|
147 | |||
148 | /** |
||
149 | * Offset to set |
||
150 | * @link http://php.net/manual/en/arrayaccess.offsetset.php |
||
151 | * |
||
152 | * @param mixed $offset <p> |
||
153 | * The offset to assign the value to. |
||
154 | * </p> |
||
155 | * @param mixed $value <p> |
||
156 | * The value to set. |
||
157 | * </p> |
||
158 | * |
||
159 | * @return void |
||
160 | * @since 5.0.0 |
||
161 | */ |
||
162 | public function offsetSet($offset, $value) |
||
167 | |||
168 | /** |
||
169 | * Offset to unset |
||
170 | * @link http://php.net/manual/en/arrayaccess.offsetunset.php |
||
171 | * |
||
172 | * @param mixed $offset <p> |
||
173 | * The offset to unset. |
||
174 | * </p> |
||
175 | * |
||
176 | * @return void |
||
177 | * @since 5.0.0 |
||
178 | */ |
||
179 | public function offsetUnset($offset) |
||
184 | } |
||
185 |