Completed
Pull Request — master (#2)
by Samuel
06:02
created

ValidationException::getCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Common\Domain;
4
5
use Symfony\Component\Validator\ConstraintViolationListInterface;
6
use GraphQL\Error\ClientAware;
7
8
class ValidationException extends \Exception implements ClientAware
9
{
10
    const DEFAULT_MESSAGE = 'The input object you try to submit is invalid';
11
12
    /**
13
     * @var ConstraintViolationListInterface
14
     */
15
    private $violations;
16
17
    /**
18
     * @param ConstraintViolationListInterface $violations
19
     * @param string $message
20
     * @param int $code
21
     * @param \Throwable|null $previous
22
     */
23
    public function __construct(ConstraintViolationListInterface $violations, $message = self::DEFAULT_MESSAGE, $code = 0, \Throwable $previous = null)
24
    {
25
        $this->violations = $violations;
26
27
        parent::__construct($message, $code, $previous);
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getCategory()
34
    {
35
        return 'Validation exception';
36
    }
37
38
    /**
39
     * @return bool
40
     */
41
    public function isClientSafe() :bool
42
    {
43
        return true;
44
    }
45
46
    /**
47
     * @return ConstraintViolationListInterface
48
     */
49
    public function getViolations() :ConstraintViolationListInterface
50
    {
51
        return $this->violations;
52
    }
53
}
54