ConstraintException::getViolations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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