1 | <?php |
||
48 | class UserValidator |
||
49 | { |
||
50 | /** |
||
51 | * @var NilPortugues\Validator\Validator |
||
52 | */ |
||
53 | private static $validator; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | private $errors = []; |
||
59 | |||
60 | /** |
||
61 | * @var bool |
||
62 | */ |
||
63 | private $isValid = true; |
||
64 | |||
65 | /** |
||
66 | * |
||
67 | */ |
||
68 | public function __construct() |
||
74 | |||
75 | /** |
||
76 | * @param Request $request |
||
77 | * |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function validate(Request $request) |
||
89 | |||
90 | /** |
||
91 | * @return array |
||
92 | */ |
||
93 | public function getErrors() |
||
97 | |||
98 | /** |
||
99 | * @param Request $request |
||
100 | * |
||
101 | * @return boolean|null |
||
102 | */ |
||
103 | private function validateGender(Request $request) |
||
116 | |||
117 | /** |
||
118 | * @param Request $request |
||
119 | * |
||
120 | * @return boolean|null |
||
121 | */ |
||
122 | private function validateEmail(Request $request) |
||
134 | |||
135 | /** |
||
136 | * @param Request $request |
||
137 | * |
||
138 | * @return boolean|null |
||
139 | */ |
||
140 | private function validatePassword(Request $request) |
||
153 | |||
154 | /** |
||
155 | * Validates is a username has alphanumeric values and is between 3 to 12 characters long. |
||
156 | * |
||
157 | * @param Request $request |
||
158 | * |
||
159 | * @return boolean|null |
||
160 | */ |
||
161 | private function validateUsername(Request $request) |
||
174 | } |
||
175 | |||
188 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.