1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Tleckie\Validator; |
6
|
|
|
|
7
|
|
|
use Tleckie\Validator\Factory\ValidatorFactoryInterface; |
8
|
|
|
use Tleckie\Validator\Validators\BoolValidator; |
9
|
|
|
use Tleckie\Validator\Validators\FloatValidator; |
10
|
|
|
use Tleckie\Validator\Validators\IntValidator; |
11
|
|
|
use Tleckie\Validator\Validators\NumericValidator; |
12
|
|
|
use Tleckie\Validator\Validators\StringValidator; |
13
|
|
|
use Tleckie\Validator\Validators\UriValidator; |
14
|
|
|
use Tleckie\Validator\Validators\ValidatorInterface; |
15
|
|
|
use Tleckie\Validator\Validators\EmailValidator; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class ValidatorFactory |
19
|
|
|
* |
20
|
|
|
* @package Tleckie\Validator |
21
|
|
|
* @author Teodoro Leckie Westberg <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class ValidatorFactory implements ValidatorFactoryInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @inheritdoc |
27
|
|
|
*/ |
28
|
|
|
public function boolValidator(): ValidatorInterface |
29
|
|
|
{ |
30
|
|
|
return new BoolValidator(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @inheritdoc |
35
|
|
|
*/ |
36
|
|
|
public function floatValidator(): ValidatorInterface |
37
|
|
|
{ |
38
|
|
|
return new FloatValidator(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @inheritdoc |
43
|
|
|
*/ |
44
|
|
|
public function intValidator(): ValidatorInterface |
45
|
|
|
{ |
46
|
|
|
return new IntValidator(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @inheritdoc |
51
|
|
|
*/ |
52
|
|
|
public function numericValidator(): ValidatorInterface |
53
|
|
|
{ |
54
|
|
|
return new NumericValidator(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @inheritdoc |
59
|
|
|
*/ |
60
|
|
|
public function stringValidator(): ValidatorInterface |
61
|
|
|
{ |
62
|
|
|
return new StringValidator(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @inheritdoc |
67
|
|
|
*/ |
68
|
|
|
public function emailValidator(): ValidatorInterface |
69
|
|
|
{ |
70
|
|
|
return new EmailValidator(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @inheritdoc |
75
|
|
|
*/ |
76
|
|
|
public function uriValidator(): ValidatorInterface |
77
|
|
|
{ |
78
|
|
|
return new UriValidator(); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|