1 | <?php |
||
10 | abstract class AbstractValidator implements ValidatorInterface |
||
11 | { |
||
12 | private ValidatorInterface $validator; |
||
|
|||
13 | |||
14 | public function __construct() |
||
15 | { |
||
16 | $this->validator = $this->create(); |
||
17 | } |
||
18 | |||
19 | abstract protected function create(): ValidatorInterface; |
||
20 | |||
21 | public function applyTo($data): ResultInterface |
||
22 | { |
||
23 | return $this->validator->applyTo($data); |
||
24 | } |
||
25 | |||
26 | public function validate($data) |
||
27 | { |
||
28 | return $this->applyTo($data)->getValidData(); |
||
29 | } |
||
30 | } |
||
31 |