| Total Complexity | 5 | 
| Total Lines | 35 | 
| Duplicated Lines | 0 % | 
| Coverage | 100% | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 13 | |||
| 14 | final class ValidationException extends \LogicException  | 
            ||
| 15 | { | 
            ||
| 16 | public const DEFAULT_MESSAGE = 'Validation error';  | 
            ||
| 17 | |||
| 18 | #[Pure]  | 
            ||
| 19 | private function __construct(  | 
            ||
| 20 | 4 | private readonly ArrayList $errors,  | 
            |
| 21 |     ) { | 
            ||
| 22 | parent::__construct(self::DEFAULT_MESSAGE);  | 
            ||
| 23 | 4 | }  | 
            |
| 24 | 4 | ||
| 25 | 4 | /** @noinspection PhpParamsInspection */  | 
            |
| 26 | public static function fromConstraintViolationList(ConstraintViolationList $violationList): self  | 
            ||
| 27 |     { | 
            ||
| 28 | 2 | return self::fromConstraintViolations(...$violationList);  | 
            |
| 29 | }  | 
            ||
| 30 | 2 | ||
| 31 | public static function fromConstraintViolations(ConstraintViolation ...$violations): self  | 
            ||
| 32 |     { | 
            ||
| 33 | 2 | return new self(ArrayList::collect($violations)->map(ValidationError::fromConstraint(...)));  | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 34 | }  | 
            ||
| 35 | 2 | ||
| 36 | public static function fromErrors(Error ...$errors): self  | 
            ||
| 37 |     { | 
            ||
| 38 | 4 | return new self(ArrayList::collect($errors));  | 
            |
| 39 | }  | 
            ||
| 40 | |||
| 41 | 4 | #[Pure]  | 
            |
| 42 | public function getErrors(): ArrayList  | 
            ||
| 43 |     { | 
            ||
| 44 | return $this->errors->toArrayList();  | 
            ||
| 45 | 3 | }  | 
            |
| 46 | |||
| 47 | 3 | public function getFormattedErrors(): array  | 
            |
| 48 |     { | 
            ||
| 56 |