Completed
Pull Request — master (#14)
by Cas
25:29
created

ValidationException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 36
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setViolations() 0 4 1
A getViolations() 0 4 1
A create() 0 7 1
1
<?php
2
3
namespace TreeHouse\BaseApiBundle\Exception;
4
5
use Symfony\Component\Validator\ConstraintViolationListInterface;
6
7
class ValidationException extends ApiException
8
{
9
    /**
10
     * @var ConstraintViolationListInterface
11
     */
12
    protected $violations;
13
14
    /**
15
     * @param ConstraintViolationListInterface $violations
16
     */
17 2
    public function setViolations(ConstraintViolationListInterface $violations)
18
    {
19 2
        $this->violations = $violations;
20 1
    }
21
22
    /**
23
     * @return ConstraintViolationListInterface
24
     */
25
    public function getViolations()
26
    {
27
        return $this->violations;
28
    }
29
30
    /**
31
     * @param ConstraintViolationListInterface $violations
32
     *
33
     * @return ValidationException
34
     */
35 2
    public static function create(ConstraintViolationListInterface $violations)
36
    {
37 1
        $exception = new ValidationException((string) $violations);
38 1
        $exception->setViolations($violations);
39
40 2
        return $exception;
41 1
    }
42
}
43