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 $fieldName |
||
39 | * @param $value |
||
40 | * @param array $constraints |
||
41 | * @param string $level |
||
42 | * @param string $propertyPath |
||
43 | */ |
||
44 | public function __construct(string $message, int $code, string $fieldName='', $value='', array $constraints=[], string $level='critical', string $propertyPath='') |
||
63 | |||
64 | /** |
||
65 | * Get the field name that was set for the assertion object. |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getFieldName() : string |
||
73 | |||
74 | /** |
||
75 | * Get the value that caused the assertion to fail. |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function getValue() |
||
83 | |||
84 | /** |
||
85 | * Get the constraints that applied to the failed assertion. |
||
86 | * |
||
87 | * @return array |
||
88 | */ |
||
89 | public function getConstraints() : array |
||
93 | |||
94 | /** |
||
95 | * Get the error level. |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getLevel() : string |
||
103 | |||
104 | /** |
||
105 | * User controlled way to define a sub-property causing |
||
106 | * the failure of a currently asserted objects. |
||
107 | * |
||
108 | * Useful to transport information about the nature of the error |
||
109 | * back to higher layers. |
||
110 | * |
||
111 | * @return string |
||
112 | */ |
||
113 | public function getPropertyPath() : string |
||
117 | |||
118 | /** |
||
119 | * Get the propertyPath, combined with the calling file and line location. |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | public function getPropertyPathAndCallingLocation() : string |
||
127 | |||
128 | /** |
||
129 | * Get the calling file and line from where the failing assertion |
||
130 | * was called. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | protected function getCallingFileAndLine() : string |
||
153 | |||
154 | /** |
||
155 | * Get the trace location of where the failing assertion |
||
156 | * was called. |
||
157 | * |
||
158 | * @return object |
||
159 | */ |
||
160 | public function getLocation() : \stdClass |
||
164 | |||
165 | /** |
||
166 | * @param string $needle |
||
167 | * @param string $haystack |
||
168 | * @param bool $returnOriginal |
||
169 | * @return string |
||
170 | */ |
||
171 | public static function afterLast(string $needle, string $haystack, bool $returnOriginal=false) : string |
||
180 | |||
181 | /** |
||
182 | * @param string $string |
||
183 | * @param string $needle |
||
184 | * @return int |
||
185 | */ |
||
186 | public static function strrevpos(string $string, string $needle) : int |
||
192 | |||
193 | /** |
||
194 | * @param string $needle |
||
195 | * @param string $haystack |
||
196 | * @return string |
||
197 | */ |
||
198 | public static function beforeLast(string $needle, string $haystack) : string |
||
204 | } |