Passed
Push — master ( 6b3343...c92a70 )
by Henri
06:46
created
src/ExtraCheck.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Validator;
4 4
 
5
-Trait ExtraCheck{
5
+Trait ExtraCheck {
6 6
     protected static array $data = [];
7 7
     protected static array $validators = [];
8 8
     protected static string $model = '';
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
     protected static function check_requireds()
13 13
     {
14
-        if(count(self::$required) > 0){
14
+        if (count(self::$required)>0) {
15 15
             self::$errors[] = [
16
-                'As seguintes informações não poderam ser validadas: '.implode(', ',array_keys(self::$required)).'.'
16
+                'As seguintes informações não poderam ser validadas: '.implode(', ', array_keys(self::$required)).'.'
17 17
             ];
18 18
         }
19 19
     }
@@ -21,22 +21,22 @@  discard block
 block discarded – undo
21 21
     public static function validateDate($date, $format = 'Y-m-d H:i:s')
22 22
     {
23 23
         $d = \DateTime::createFromFormat($format, $date);
24
-        return $d && $d->format($format) == $date;
24
+        return $d && $d->format($format)==$date;
25 25
     }
26 26
 
27 27
     protected static function check_required(string $param): bool
28 28
     {
29
-        return (array_key_exists('required',self::$validators[self::$model]->getRules(self::$data['role'])[$param]) && self::$validators[self::$model]->getRules(self::$data['role'])[$param]['required']);
29
+        return (array_key_exists('required', self::$validators[self::$model]->getRules(self::$data['role'])[$param]) && self::$validators[self::$model]->getRules(self::$data['role'])[$param]['required']);
30 30
     }
31 31
 
32 32
     protected static function toNext(string $param, $value)
33 33
     {
34
-        return (self::check_required($param) || strlen($value > 0));
34
+        return (self::check_required($param) || strlen($value>0));
35 35
     }
36 36
 
37 37
     protected static function testArray(string $param, $value): ?array
38 38
     {
39
-        if(!is_array(json_decode($value))){
39
+        if (!is_array(json_decode($value))) {
40 40
             self::$errors[] = [
41 41
                 $param => 'Era esperado uma informação em formato array para está informação.'
42 42
             ];
Please login to merge, or discard this patch.
examples/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
         'password' => 123456,
13 13
         'password2' => 123456,
14 14
         'phones' => json_encode([
15
-            '949164770','949164771','949164772'
15
+            '949164770', '949164771', '949164772'
16 16
         ]),
17 17
         'birth' => '28/09/1996' 
18 18
     ]),
@@ -20,16 +20,16 @@  discard block
 block discarded – undo
20 20
     'role' => 'login'
21 21
 ];
22 22
 
23
-try{
23
+try {
24 24
 
25 25
     /* Checks whether the passed data is valid for the selected function */
26 26
     $valid = Validator::execute($data);
27 27
     
28
-    if(!$valid){
28
+    if (!$valid) {
29 29
         $errors = [];
30
-        foreach(Validator::getErrors() as $err => $message){
30
+        foreach (Validator::getErrors() as $err => $message) {
31 31
             $errors[] = [
32
-                'input' => array_keys($message)[0],                 // Return name input error
32
+                'input' => array_keys($message)[0], // Return name input error
33 33
                 'message' => $message[array_keys($message)[0]]      // Return message error
34 34
             ];
35 35
         }
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     /* Transforms validation to Json format to be validated on the client if desired */
39 39
     $json = Validator::toJson($data);
40 40
 
41
-}catch(Exception $er){
41
+}catch (Exception $er) {
42 42
 
43 43
     die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}.");
44 44
 
Please login to merge, or discard this patch.