ErrorInvalidArgumentException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromConstraintValidation() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Exception;
6
7
use JetBrains\PhpStorm\Immutable;
8
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
9
use Symfony\Component\Validator\ConstraintViolationInterface as ConstraintViolation;
10
11
#[Immutable]
12
#[CodeCoverageIgnore('This error should never be thrown')]
13
final class ErrorInvalidArgumentException extends \InvalidArgumentException
14
{
15
    public static function fromConstraintValidation(ConstraintViolation $violation, ?\Throwable $previous = null): self
16
    {
17
        $message = sprintf(
18
            'Validation Constraint: [%s] [%s] [%s]',
19
            $violation->getPropertyPath(),
20
            (string) $violation->getCode(),
21
            (string) $violation->getMessage(),
22
        );
23
24
        return new self($message, previous: $previous);
25
    }
26
}
27