1 | <?php declare(strict_types=1); |
||
24 | class AssertionFailedException extends \Exception |
||
25 | { |
||
26 | private $fieldName; |
||
27 | private $value; |
||
28 | private $constraints; |
||
29 | private $level; |
||
30 | private $propertyPath; |
||
31 | private $location; |
||
32 | |||
33 | /** |
||
34 | * AssertionFailedException constructor. |
||
35 | * |
||
36 | * @param string $message |
||
37 | * @param int $code |
||
38 | * @param string $propertyPath |
||
39 | * @param $value |
||
40 | * @param array $constraints |
||
41 | * @param string $level |
||
42 | */ |
||
43 | public function __construct(string $message, int $code, string $fieldName = '', $value, array $constraints=[], string $level='critical', string $propertyPath = '') |
||
64 | |||
65 | /** |
||
66 | * Get the field name that was set for the assertion object. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getFieldName() : string |
||
74 | |||
75 | /** |
||
76 | * Get the value that caused the assertion to fail. |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getValue() |
||
84 | |||
85 | /** |
||
86 | * Get the constraints that applied to the failed assertion. |
||
87 | * |
||
88 | * @return array |
||
89 | */ |
||
90 | public function getConstraints() : array |
||
94 | |||
95 | /** |
||
96 | * Get the error level. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getLevel() : string |
||
104 | |||
105 | /** |
||
106 | * User controlled way to define a sub-property causing |
||
107 | * the failure of a currently asserted objects. |
||
108 | * |
||
109 | * Useful to transport information about the nature of the error |
||
110 | * back to higher layers. |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getPropertyPath() : string |
||
118 | |||
119 | /** |
||
120 | * Get the propertyPath, combined with the calling file and line location. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getPropertyPathAndCallingLocation() : string |
||
128 | |||
129 | /** |
||
130 | * Get the calling file and line from where the failing assertion |
||
131 | * was called. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | protected function getCallingFileAndLine() : string |
||
154 | |||
155 | /** |
||
156 | * Get the trace location of where the failing assertion |
||
157 | * was called. |
||
158 | * |
||
159 | * @return object |
||
160 | */ |
||
161 | public function getLocation() : object |
||
165 | |||
166 | /** |
||
167 | * @param string $needle |
||
168 | * @param string $haystack |
||
169 | * @param bool $return_original |
||
170 | * @return string |
||
171 | */ |
||
172 | public static function afterLast(string $needle, string $haystack, bool $return_original=false) : string |
||
181 | |||
182 | /** |
||
183 | * @param string $string |
||
184 | * @param string $needle |
||
185 | * @return int |
||
186 | */ |
||
187 | public static function strrevpos(string $string, string $needle) : int |
||
193 | |||
194 | /** |
||
195 | * @param string $needle |
||
196 | * @param string $haystack |
||
197 | * @return string |
||
198 | */ |
||
199 | public static function beforeLast(string $needle, string $haystack) : string |
||
205 | } |