Completed
Push — master ( ad3b69...02c092 )
by John
09:08 queued 05:48
created

ValidationException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 4
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Exception;
10
11
/**
12
 * @author John Kleijn <[email protected]>
13
 */
14
class ValidationException extends \Exception
15
{
16
    const MESSAGE_INPUT = 'Input validation failed';
17
    const MESSAGE_OUTPUT = 'Output validation failed';
18
19
    /**
20
     * @var array
21
     */
22
    private $validationErrors;
23
24
    /**
25
     * @param string     $message
26
     * @param int        $code
27
     * @param array      $validationErrors
28
     * @param \Exception $previous
29
     */
30
    public function __construct(
31
        array $validationErrors,
32
        int $code = 400,
33
        string $message = self::MESSAGE_INPUT,
34
        \Exception $previous = null
35
    ) {
36
        parent::__construct($message, $code, $previous);
37
38
        $this->validationErrors = $validationErrors;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function getValidationErrors(): array
45
    {
46
        return $this->validationErrors;
47
    }
48
}
49