Total Complexity | 3 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | final class RuleException extends RuntimeException |
||
14 | { |
||
15 | /** |
||
16 | * @var RuleInterface Rule that could not be enforced. |
||
17 | */ |
||
18 | private $rule; |
||
19 | |||
20 | /** |
||
21 | * @var int Weight of violated constraint. |
||
22 | */ |
||
23 | private $weight; |
||
24 | |||
25 | /** |
||
26 | * @param RuleInterface $rule Rule that could not be enforced. |
||
27 | * @param int $weight Weight of violated constraint. |
||
28 | * @param string $message Exception message. |
||
29 | * @param Throwable|null $previous Previous exception, used for exception chaining. |
||
30 | */ |
||
31 | 1 | public function __construct(RuleInterface $rule, int $weight, string $message, ?Throwable $previous = null) |
|
32 | { |
||
33 | 1 | $this->rule = $rule; |
|
34 | 1 | $this->weight = $weight; |
|
35 | |||
36 | 1 | parent::__construct($message, /*code*/0, $previous); |
|
37 | 1 | } |
|
38 | |||
39 | /** |
||
40 | * @return RuleInterface Rule that could not be enforced. |
||
41 | */ |
||
42 | 1 | public function getRule(): RuleInterface |
|
43 | { |
||
44 | 1 | return $this->rule; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return int Weight of violated constraint. |
||
49 | */ |
||
50 | 1 | public function getWeight(): int |
|
53 | } |
||
54 | } |
||
55 |