ValidationException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getViolations() 0 3 1
A __construct() 0 9 1
1
<?php
2
3
namespace DMT\CommandBus\Validator;
4
5
use Symfony\Component\Validator\ConstraintViolationListInterface;
6
use Throwable;
7
8
/**
9
 * Class ValidationException
10
 *
11
 * @package DMT\Validation
12
 */
13
class ValidationException extends \RuntimeException
14
{
15
    /**
16
     * @var ConstraintViolationListInterface
17
     */
18
    protected $violations;
19
20
    /**
21
     * ValidationException constructor.
22
     *
23
     * @param string $message
24
     * @param int $code
25
     * @param Throwable|null $previous
26
     * @param ConstraintViolationListInterface|null $violations
27
     */
28 4
    public function __construct(
29
        string $message = "Invalid command",
30
        int $code = 0,
31
        Throwable $previous = null,
32
        ConstraintViolationListInterface $violations = null
33
    ) {
34 4
        parent::__construct($message, $code, $previous);
35
36 4
        $this->violations = $violations;
37 4
    }
38
39 2
    public function getViolations(): ?ConstraintViolationListInterface
40
    {
41 2
        return $this->violations;
42
    }
43
}
44