Completed
Pull Request — master (#37)
by Peter
23:57
created

ValidationException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 36
ccs 7
cts 14
cp 0.5
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\IoBundle\Exception;
4
5
use Symfony\Component\Validator\ConstraintViolationListInterface;
6
7
class ValidationException extends \Exception
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 2
    }
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 2
        $exception = new static((string) $violations);
38 2
        $exception->setViolations($violations);
39
40 2
        return $exception;
41
    }
42
}
43