ConstraintException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromConstraintViolationList() 0 4 1
A getViolations() 0 3 1
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