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