fromConstraintValidation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
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