Passed
Push — main ( 0f5def...1304a4 )
by Fractal
02:54
created

ConstraintException::fromConstraintViolationList()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FRZB\Component\RequestMapper\Exception;
6
7
use JetBrains\PhpStorm\Pure;
8
use Symfony\Component\Validator\ConstraintViolationListInterface as ConstraintViolationList;
9
10
final class ConstraintException extends \LogicException
11
{
12
    private const DEFAULT_MESSAGE = 'Constraint Exception';
13
14 2
    #[Pure]
15 2
    private function __construct(private readonly ConstraintViolationList $violations, ?\Throwable $previous = null)
16
    {
17 2
        parent::__construct(self::DEFAULT_MESSAGE, 0, $previous);
18
    }
19
20 2
    #[Pure]
21
    public static function fromConstraintViolationList(ConstraintViolationList $violationList, ?\Throwable $previous = null): self
22
    {
23 2
        return new self($violationList, previous: $previous);
24
    }
25
26 2
    public function getViolations(): ConstraintViolationList
27
    {
28 2
        return $this->violations;
29
    }
30
}
31