| 1 | <?php |
||
| 10 | abstract class AbstractValidator implements ValidatorInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var callable Callback on exception |
||
| 14 | */ |
||
| 15 | private $onExceptionCallback = [__CLASS__, 'defaultOnExceptionCallback']; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Register on-exception callback |
||
| 19 | * |
||
| 20 | * The callback should take an \Exception object and proccess it as |
||
| 21 | * appropriate. This generally means throwing an exception of some kind |
||
| 22 | * or returning a replacement value. |
||
| 23 | */ |
||
| 24 | public function onException(callable $callback): self |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Call the on-exception callback |
||
| 32 | * |
||
| 33 | * @return mixed Whatever the callback returns |
||
| 34 | */ |
||
| 35 | protected function fireException(\Exception $exception) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Simple callback that throws exceptions |
||
| 42 | * |
||
| 43 | * @throws \Exception throws supplied exception |
||
| 44 | */ |
||
| 45 | protected static function defaultOnExceptionCallback(\Exception $exception): void |
||
| 49 | |||
| 50 | public function __invoke($tainted) |
||
| 54 | } |
||
| 55 |