Total Complexity | 6 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 92.31% |
Changes | 0 |
1 | <?php |
||
22 | abstract class AbstractRule implements RuleInterface |
||
23 | { |
||
24 | /** |
||
25 | * Message for error output |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $description = 'is invalid'; |
||
29 | |||
30 | /** |
||
31 | * @inheritdoc |
||
32 | */ |
||
33 | 7 | public function assert($input): void |
|
34 | { |
||
35 | 7 | if (!$this->validate($input)) { |
|
36 | 7 | throw new ValidatorException($this->description); |
|
37 | } |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | 14 | public function __invoke($input): bool |
|
44 | { |
||
45 | 14 | return $this->validate($input); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @inheritdoc |
||
50 | */ |
||
51 | 435 | public function __toString(): string |
|
52 | { |
||
53 | 435 | return $this->getDescription(); |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | 197 | public function getDescription(): string |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @inheritdoc |
||
66 | */ |
||
67 | 4 | public function setDescription(string $description): RuleInterface |
|
71 | } |
||
72 | } |
||
73 |