Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
Validator | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
setForm | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
form | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
message | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
validate | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | |
3 | namespace Dynart\Micro; |
4 | |
5 | abstract class Validator { |
6 | |
7 | /** @var Form */ |
8 | protected $form; |
9 | protected $message; |
10 | |
11 | /** |
12 | * Assigns a form to this validator |
13 | * @param Form $form |
14 | */ |
15 | public function setForm(Form $form): void { |
16 | $this->form = $form; |
17 | } |
18 | |
19 | /** |
20 | * Returns with the assigned form |
21 | * @return Form |
22 | */ |
23 | public function form(): Form { |
24 | return $this->form; |
25 | } |
26 | |
27 | /** |
28 | * The message after validation |
29 | * @return string |
30 | */ |
31 | public function message(): string { |
32 | return $this->message; |
33 | } |
34 | |
35 | abstract public function validate($value); |
36 | |
37 | } |