@@ -9,7 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * @var \System\Application |
11 | 11 | */ |
12 | - protected $app; |
|
12 | + protected $app; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Constructor |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | class Date |
7 | 7 | { |
8 | - private $start; |
|
9 | - private $end; |
|
10 | - private $format; |
|
11 | - private $value; |
|
12 | - private $year; |
|
8 | + private $start; |
|
9 | + private $end; |
|
10 | + private $format; |
|
11 | + private $value; |
|
12 | + private $year; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Constructor |
@@ -73,7 +73,9 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function require($call = true, $msg = null) |
75 | 75 | { |
76 | - if ($call === false) return $this; |
|
76 | + if ($call === false) { |
|
77 | + return $this; |
|
78 | + } |
|
77 | 79 | |
78 | 80 | $value = $this->value(); |
79 | 81 | |
@@ -105,11 +107,15 @@ discard block |
||
105 | 107 | */ |
106 | 108 | public function email($call = true, $msg = null) |
107 | 109 | { |
108 | - if ($call === false) return $this; |
|
110 | + if ($call === false) { |
|
111 | + return $this; |
|
112 | + } |
|
109 | 113 | |
110 | 114 | $value = $this->value(); |
111 | 115 | |
112 | - if (!$value && $value != '0') return $this; |
|
116 | + if (!$value && $value != '0') { |
|
117 | + return $this; |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { |
115 | 121 | $msg = $msg ?: 'e-mail is not valid'; |
@@ -128,11 +134,15 @@ discard block |
||
128 | 134 | */ |
129 | 135 | public function image($call = true, $msg = null) |
130 | 136 | { |
131 | - if ($call === false) return $this; |
|
137 | + if ($call === false) { |
|
138 | + return $this; |
|
139 | + } |
|
132 | 140 | |
133 | 141 | $file = $this->app->request->file($this->input); |
134 | 142 | |
135 | - if (!$file->exists()) return $this; |
|
143 | + if (!$file->exists()) { |
|
144 | + return $this; |
|
145 | + } |
|
136 | 146 | |
137 | 147 | if (!$file->isImage()) { |
138 | 148 | $msg = $msg ?: 'image is not valid'; |
@@ -151,11 +161,15 @@ discard block |
||
151 | 161 | */ |
152 | 162 | public function number($call = true, $msg = null) |
153 | 163 | { |
154 | - if ($call === false) return $this; |
|
164 | + if ($call === false) { |
|
165 | + return $this; |
|
166 | + } |
|
155 | 167 | |
156 | 168 | $value = $this->value(); |
157 | 169 | |
158 | - if (!$value && $value != '0') return $this; |
|
170 | + if (!$value && $value != '0') { |
|
171 | + return $this; |
|
172 | + } |
|
159 | 173 | |
160 | 174 | if (!is_numeric($value)) { |
161 | 175 | $msg = $msg ?: 'this field must be a number'; |
@@ -174,11 +188,15 @@ discard block |
||
174 | 188 | */ |
175 | 189 | public function float($call = true, $msg = null) |
176 | 190 | { |
177 | - if ($call === false) return $this; |
|
191 | + if ($call === false) { |
|
192 | + return $this; |
|
193 | + } |
|
178 | 194 | |
179 | 195 | $value = $this->value(); |
180 | 196 | |
181 | - if (!$value && $value != '0') return $this; |
|
197 | + if (!$value && $value != '0') { |
|
198 | + return $this; |
|
199 | + } |
|
182 | 200 | |
183 | 201 | if (!is_float($value)) { |
184 | 202 | $msg = $msg ?: "this field must be a float number"; |
@@ -199,11 +217,15 @@ discard block |
||
199 | 217 | */ |
200 | 218 | public function date($options = [], $msg = null) |
201 | 219 | { |
202 | - if ($options === false) return $this; |
|
220 | + if ($options === false) { |
|
221 | + return $this; |
|
222 | + } |
|
203 | 223 | |
204 | 224 | $value = $this->value(); |
205 | 225 | |
206 | - if (!$value && $value != '0') return $this; |
|
226 | + if (!$value && $value != '0') { |
|
227 | + return $this; |
|
228 | + } |
|
207 | 229 | |
208 | 230 | $options = json_encode($options); |
209 | 231 | $options = json_decode($options); |
@@ -244,11 +266,15 @@ discard block |
||
244 | 266 | */ |
245 | 267 | public function text($call = true, $msg = null) |
246 | 268 | { |
247 | - if ($call === false) return $this; |
|
269 | + if ($call === false) { |
|
270 | + return $this; |
|
271 | + } |
|
248 | 272 | |
249 | 273 | $value = $this->value(); |
250 | 274 | |
251 | - if (!$value && $value != '0') return $this; |
|
275 | + if (!$value && $value != '0') { |
|
276 | + return $this; |
|
277 | + } |
|
252 | 278 | |
253 | 279 | if (!is_string($value)) { |
254 | 280 | $msg = $msg ?: 'the field must be a text'; |
@@ -267,11 +293,15 @@ discard block |
||
267 | 293 | */ |
268 | 294 | public function noNumbers($call = true, $msg = null) |
269 | 295 | { |
270 | - if ($call === false) return $this; |
|
296 | + if ($call === false) { |
|
297 | + return $this; |
|
298 | + } |
|
271 | 299 | |
272 | 300 | $value = $this->value(); |
273 | 301 | |
274 | - if (!$value && $value != '0') return $this; |
|
302 | + if (!$value && $value != '0') { |
|
303 | + return $this; |
|
304 | + } |
|
275 | 305 | |
276 | 306 | if (preg_match('~[0-9]~', $value)) { |
277 | 307 | $msg = $msg ?: 'numbers are not allow'; |
@@ -291,11 +321,15 @@ discard block |
||
291 | 321 | */ |
292 | 322 | public function characters($excepts, $msg = null) |
293 | 323 | { |
294 | - if ($excepts === false) return $this; |
|
324 | + if ($excepts === false) { |
|
325 | + return $this; |
|
326 | + } |
|
295 | 327 | |
296 | 328 | $value = $this->value(); |
297 | 329 | |
298 | - if (!$value && $value != '0') return $this; |
|
330 | + if (!$value && $value != '0') { |
|
331 | + return $this; |
|
332 | + } |
|
299 | 333 | |
300 | 334 | $characters = new Characters($excepts); |
301 | 335 | $chars = $characters->getChars(); |
@@ -429,11 +463,15 @@ discard block |
||
429 | 463 | */ |
430 | 464 | public function noSpaces($call = true, $msg = null) |
431 | 465 | { |
432 | - if ($call === false) return $this; |
|
466 | + if ($call === false) { |
|
467 | + return $this; |
|
468 | + } |
|
433 | 469 | |
434 | 470 | $value = $this->value(); |
435 | 471 | |
436 | - if (!$value && $value != '0') return $this; |
|
472 | + if (!$value && $value != '0') { |
|
473 | + return $this; |
|
474 | + } |
|
437 | 475 | |
438 | 476 | if (preg_match('/\s/', $value)) { |
439 | 477 | $msg = $msg ?: 'spaces are not allow'; |
@@ -452,11 +490,15 @@ discard block |
||
452 | 490 | */ |
453 | 491 | public function containJust($characters = [], $msg = null) |
454 | 492 | { |
455 | - if ($characters === false) return $this; |
|
493 | + if ($characters === false) { |
|
494 | + return $this; |
|
495 | + } |
|
456 | 496 | |
457 | 497 | $value = $this->value(); |
458 | 498 | |
459 | - if (!$value && $value != '0') return $this; |
|
499 | + if (!$value && $value != '0') { |
|
500 | + return $this; |
|
501 | + } |
|
460 | 502 | |
461 | 503 | if (!is_array($characters) && $characters !== '') { |
462 | 504 | $characters = [$characters]; |
@@ -532,11 +574,15 @@ discard block |
||
532 | 574 | */ |
533 | 575 | public function length($length = null, $msg = null) |
534 | 576 | { |
535 | - if ($length === false) return $this; |
|
577 | + if ($length === false) { |
|
578 | + return $this; |
|
579 | + } |
|
536 | 580 | |
537 | 581 | $value = $this->value(); |
538 | 582 | |
539 | - if (!$value && $value != '0') return $this; |
|
583 | + if (!$value && $value != '0') { |
|
584 | + return $this; |
|
585 | + } |
|
540 | 586 | |
541 | 587 | if (strlen($value) !== $length) { |
542 | 588 | $msg = $msg ?: `this field can be just ${length} charachter`; |
@@ -555,11 +601,15 @@ discard block |
||
555 | 601 | */ |
556 | 602 | public function maxLen($length = null, $msg = null) |
557 | 603 | { |
558 | - if ($length === false) return $this; |
|
604 | + if ($length === false) { |
|
605 | + return $this; |
|
606 | + } |
|
559 | 607 | |
560 | 608 | $value = $this->value(); |
561 | 609 | |
562 | - if (!$value && $value != '0') return $this; |
|
610 | + if (!$value && $value != '0') { |
|
611 | + return $this; |
|
612 | + } |
|
563 | 613 | |
564 | 614 | if (strlen($value) > $length) { |
565 | 615 | $msg = $msg ?: "this field can be maximum $length charachter"; |
@@ -578,11 +628,15 @@ discard block |
||
578 | 628 | */ |
579 | 629 | public function minLen($length = null, $msg = null) |
580 | 630 | { |
581 | - if ($length === false) return $this; |
|
631 | + if ($length === false) { |
|
632 | + return $this; |
|
633 | + } |
|
582 | 634 | |
583 | 635 | $value = $this->value(); |
584 | 636 | |
585 | - if (!$value && $value != '0') return $this; |
|
637 | + if (!$value && $value != '0') { |
|
638 | + return $this; |
|
639 | + } |
|
586 | 640 | |
587 | 641 | if (strlen($value) < $length) { |
588 | 642 | $msg = $msg ?: "this field can be minimum $length charachter"; |
@@ -601,7 +655,9 @@ discard block |
||
601 | 655 | */ |
602 | 656 | public function match($input, $msg = null) |
603 | 657 | { |
604 | - if ($input === false) return $this; |
|
658 | + if ($input === false) { |
|
659 | + return $this; |
|
660 | + } |
|
605 | 661 | |
606 | 662 | $value = $this->value(); |
607 | 663 | |
@@ -626,11 +682,15 @@ discard block |
||
626 | 682 | */ |
627 | 683 | public function unique($data = [], $msg = null) |
628 | 684 | { |
629 | - if ($data === false) return $this; |
|
685 | + if ($data === false) { |
|
686 | + return $this; |
|
687 | + } |
|
630 | 688 | |
631 | 689 | $value = $this->value(); |
632 | 690 | |
633 | - if (!$data) return $this; |
|
691 | + if (!$data) { |
|
692 | + return $this; |
|
693 | + } |
|
634 | 694 | |
635 | 695 | if (is_array($data)) { |
636 | 696 | list($table, $column) = $data; |
@@ -688,7 +748,9 @@ discard block |
||
688 | 748 | */ |
689 | 749 | public function addError($input, $msg) |
690 | 750 | { |
691 | - if (!$this->hasError($input)) $this->errors[$input] = $msg; |
|
751 | + if (!$this->hasError($input)) { |
|
752 | + $this->errors[$input] = $msg; |
|
753 | + } |
|
692 | 754 | } |
693 | 755 | |
694 | 756 | /** |