ValidationException::getViolations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
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 2
cts 2
cp 1
crap 1
rs 10
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