| Total Complexity | 2 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class TransformerExceptionConstraint extends Constraint |
||
| 12 | { |
||
| 13 | const TRANSFORM_ERROR = 'b5acab45-80b0-4808-8784-6577e37ac869'; |
||
| 14 | |||
| 15 | protected static $errorNames = [ |
||
| 16 | self::TRANSFORM_ERROR => 'TRANSFORM_ERROR', |
||
| 17 | ]; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The error message. If null, the exception's message will be taken |
||
| 21 | * |
||
| 22 | * @var string|null |
||
| 23 | */ |
||
| 24 | public $message = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * The error code |
||
| 28 | * |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | public $code = self::TRANSFORM_ERROR; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The transformer exception |
||
| 35 | * |
||
| 36 | * @var Exception |
||
| 37 | */ |
||
| 38 | public $exception; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Use to validate the exception |
||
| 42 | * If the closure returns false, the transformer error will be ignored |
||
| 43 | * |
||
| 44 | * Note: To change the message or code corresponding to the exception, set code or message attributes on the constraint |
||
| 45 | * |
||
| 46 | * @var callable(mixed,TransformerExceptionConstraint,\Bdf\Form\ElementInterface):bool|null |
||
| 47 | */ |
||
| 48 | public $validationCallback; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Does the transformation error should be ignored ? |
||
| 52 | * If true, the transformation exception will be ignored |
||
| 53 | * |
||
| 54 | * @var bool |
||
| 55 | */ |
||
| 56 | public $ignoreException = false; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | 434 | public function getDefaultOption() |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Set the exception on the constraint |
||
| 68 | * |
||
| 69 | * @param Exception $exception |
||
| 70 | * @return static |
||
| 71 | */ |
||
| 72 | 22 | public function withException(Exception $exception): self |
|
| 80 |