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

ConstraintException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
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\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