InvalidCommandException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 47
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onCommand() 0 12 1
A getCommand() 0 4 1
A getViolations() 0 4 1
1
<?php
2
3
namespace League\Tactician\Bundle\Middleware;
4
5
use League\Tactician\Exception\Exception;
6
use Symfony\Component\Validator\ConstraintViolationListInterface;
7
8
class InvalidCommandException extends \Exception implements Exception
9
{
10
    /**
11
     * @var object
12
     */
13
    protected $command;
14
15
    /**
16
     * @var ConstraintViolationListInterface
17
     */
18
    protected $violations;
19
20
    /**
21
     * @param object $command
22
     * @param ConstraintViolationListInterface $violations
23
     *
24
     * @return static
25
     */
26 3
    public static function onCommand($command, ConstraintViolationListInterface $violations)
27
    {
28 3
        $exception = new static(
29 3
            'Validation failed for ' . get_class($command) .
30 3
            ' with ' . $violations->count() . ' violation(s).'
31
        );
32
33 3
        $exception->command    = $command;
34 3
        $exception->violations = $violations;
35
36 3
        return $exception;
37
    }
38
39
    /**
40
     * @return object
41
     */
42 3
    public function getCommand()
43
    {
44 3
        return $this->command;
45
    }
46
47
    /**
48
     * @return ConstraintViolationListInterface
49
     */
50 3
    public function getViolations()
51
    {
52 3
        return $this->violations;
53
    }
54
}
55