1 | <?php namespace Limoncello\Validation\Captures; |
||
26 | abstract class BaseCapture implements RuleInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var RuleInterface |
||
30 | */ |
||
31 | private $rule; |
||
32 | |||
33 | /** |
||
34 | * @var bool |
||
35 | */ |
||
36 | private $hadErrors = false; |
||
37 | |||
38 | /** |
||
39 | * If capture actually had some input data and did validation. |
||
40 | * |
||
41 | * @var bool |
||
42 | */ |
||
43 | private $isValidated = false; |
||
44 | |||
45 | /** |
||
46 | * @var CaptureAggregatorInterface |
||
47 | */ |
||
48 | private $aggregator; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | private $name; |
||
54 | |||
55 | /** |
||
56 | * @param mixed $data |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | abstract protected function capture($data); |
||
61 | |||
62 | /** |
||
63 | * @return mixed |
||
64 | */ |
||
65 | abstract protected function getCapturedData(); |
||
66 | |||
67 | /** |
||
68 | * @param string $name |
||
69 | * @param RuleInterface $rule |
||
70 | * @param CaptureAggregatorInterface $aggregator |
||
71 | */ |
||
72 | 5 | public function __construct($name, RuleInterface $rule, CaptureAggregatorInterface $aggregator) |
|
78 | |||
79 | /** |
||
80 | * @inheritdoc |
||
81 | */ |
||
82 | 5 | public function validate($input) |
|
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | */ |
||
100 | 1 | public function isStateless() |
|
104 | |||
105 | /** |
||
106 | * @inheritdoc |
||
107 | */ |
||
108 | 5 | public function setParentRule(RuleInterface $parent) |
|
112 | |||
113 | /** |
||
114 | * @inheritdoc |
||
115 | */ |
||
116 | 3 | public function getParameterName() |
|
120 | |||
121 | /** |
||
122 | * @inheritdoc |
||
123 | */ |
||
124 | 3 | public function setParameterName($parameterName) |
|
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | 5 | public function onFinish(ErrorAggregatorInterface $aggregator) |
|
145 | |||
146 | /** |
||
147 | * @return CaptureAggregatorInterface |
||
148 | */ |
||
149 | 4 | protected function getAggregator() |
|
153 | |||
154 | /** |
||
155 | * @return RuleInterface |
||
156 | */ |
||
157 | 5 | protected function getRule() |
|
161 | |||
162 | /** |
||
163 | * @return string |
||
164 | */ |
||
165 | 4 | protected function getCaptureName() |
|
169 | |||
170 | /** |
||
171 | * @return boolean |
||
172 | */ |
||
173 | 5 | protected function hadErrors() |
|
177 | |||
178 | /** |
||
179 | * @return boolean |
||
180 | */ |
||
181 | 5 | protected function isValidated() |
|
185 | } |
||
186 |