Completed
Push — feature/authentication_cleanup ( dfa3b9...c02d17 )
by Bastian
17:41 queued 02:00
created

ValidationException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 29
ccs 0
cts 9
cp 0
rs 10

2 Methods

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