1 | <?php namespace Limoncello\Validation; |
||
30 | class SingleValidator extends BaseValidator |
||
31 | { |
||
32 | use SingleValidation; |
||
33 | |||
34 | /** |
||
35 | * @var ContainerInterface|null |
||
36 | */ |
||
37 | private $container; |
||
38 | |||
39 | /** |
||
40 | * @param RuleInterface $rule |
||
41 | * @param ContainerInterface|null $container |
||
42 | */ |
||
43 | 4 | public function __construct(RuleInterface $rule, ContainerInterface $container = null) |
|
51 | |||
52 | /** |
||
53 | * @param RuleInterface $rule |
||
54 | * @param ContainerInterface|null $container |
||
55 | * |
||
56 | * @return ValidatorInterface |
||
57 | */ |
||
58 | 4 | public static function validator(RuleInterface $rule, ContainerInterface $container = null): ValidatorInterface |
|
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | * |
||
68 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
69 | */ |
||
70 | 4 | public function validate($input): bool |
|
83 | |||
84 | /** |
||
85 | * @return ContainerInterface|null |
||
86 | */ |
||
87 | 4 | protected function getContainer(): ?ContainerInterface |
|
91 | |||
92 | /** |
||
93 | * During validation you can pass to rules your custom context which might have any additional |
||
94 | * resources needed by your rules (extra properties, database connection settings, container, and etc). |
||
95 | * |
||
96 | * @param array $blocks |
||
97 | * |
||
98 | * @return ContextStorageInterface |
||
99 | */ |
||
100 | 4 | protected function createContextStorageFromBlocks(array $blocks): ContextStorageInterface |
|
104 | } |
||
105 |