ValidationException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
/**
3
 * Validation exception class
4
 */
5
6
namespace Graviton\ExceptionBundle\Exception;
7
8
use Symfony\Component\HttpFoundation\Response;
9
10
/**
11
 * Validation exception class
12
 *
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  https://opensource.org/licenses/MIT MIT License
15
 * @link     http://swisscom.ch
16
 */
17
final class ValidationException extends RestException
18
{
19
    /**
20
     * Violations
21
     *
22
     * @var FormErrorIterator
23
     */
24
    private $errors;
25
26
    /**
27
     * Constructor
28
     *
29
     * @param FormErrorIterator $errors  Errors from form
30
     * @param string            $message Error message
31
     */
32
    public function __construct(FormErrorIterator $errors, $message = 'Validation failed')
33
    {
34
        $this->errors = $errors;
35
        parent::__construct(Response::HTTP_BAD_REQUEST, $message);
36
    }
37
38
    /**
39
     * @return FormErrorIterator
40
     */
41
    public function getErrors()
42
    {
43
        return $this->errors;
44
    }
45
}
46