1 | <?php |
||
7 | abstract class AbstractValidator |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $errors; |
||
13 | |||
14 | /** |
||
15 | * @var bool |
||
16 | */ |
||
17 | protected $isValid; |
||
18 | |||
19 | /** |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $isValidCalled; |
||
23 | |||
24 | 35 | public function __construct() |
|
30 | |||
31 | /** |
||
32 | * @param AbstractTracking $transfer |
||
33 | * @throws \RuntimeException |
||
34 | * @return bool |
||
35 | */ |
||
36 | 30 | public function isValid(AbstractTracking $transfer) |
|
49 | |||
50 | /** |
||
51 | * The implementation must add the errors into the errors property. For example: |
||
52 | * |
||
53 | * $this->errors = [ |
||
54 | * 0 => 'error 1', |
||
55 | * 1 => 'error 2', |
||
56 | * ] |
||
57 | * |
||
58 | * @param $transfer |
||
59 | * @return bool |
||
60 | */ |
||
61 | protected abstract function validate($transfer); |
||
62 | |||
63 | /** |
||
64 | * @return array |
||
65 | * @throws \RuntimeException |
||
66 | */ |
||
67 | 30 | public function getErrors() |
|
75 | |||
76 | /** |
||
77 | * @param AbstractValidator $validator |
||
78 | * @return string |
||
79 | */ |
||
80 | 30 | protected function getExpectedValidatorName(AbstractValidator $validator) |
|
90 | } |
||
91 |