Passed
Push — master ( e7f31c...ff523f )
by Jesús
14:45
created
ValidatorInterface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
      * @param array $data array of data to be validated.
17 17
      * @return ValidatorInterface current instance of the validator.
18 18
      */
19
-    public function with( array $data );
19
+    public function with(array $data);
20 20
 
21 21
     /**
22 22
      * Performs the given validation against the given data passed on "with()".
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      * @return mixed bool TRUE if it passes the validation, FALSE if it fails. For more info, retrieve errors after the fail.
26 26
      * @throws ValidationFunctionDoesNotExist
27 27
      */
28
-    public function passes( $setOfRules );
28
+    public function passes($setOfRules);
29 29
 
30 30
     /**
31 31
      * Returns an array of validation errors that may be empty.
@@ -40,5 +40,5 @@  discard block
 block discarded – undo
40 40
      * @param $key string Key to fetch.
41 41
      * @return mixed value for requested key or NULL if key does not exist.
42 42
      */
43
-    public function get( $key );
43
+    public function get($key);
44 44
 }
45 45
\ No newline at end of file
Please login to merge, or discard this patch.
src/LaravelValidator.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @param Factory $validator
23 23
      */
24
-    public function __construct( Factory $validator )
24
+    public function __construct(Factory $validator)
25 25
     {
26 26
         $this->validator = $validator;
27 27
     }
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      * @param array $data
32 32
      * @return $this
33 33
      */
34
-    public function with( array $data )
34
+    public function with(array $data)
35 35
     {
36 36
         $this->data = $data;
37 37
         return $this;
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
      * @return bool
44 44
      * @throws ValidationFunctionDoesNotExist
45 45
      */
46
-    public function passes( $setOfRules )
46
+    public function passes($setOfRules)
47 47
     {
48
-        if ( is_string( $setOfRules ) || is_array( $setOfRules ) )
48
+        if (is_string($setOfRules) || is_array($setOfRules))
49 49
         {
50 50
             $validator = NULL;
51
-            if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) $validator = $this->validator->make( $this->data, $this->{$setOfRules}() );
52
-            else if ( is_array( $setOfRules ) ) $validator = $this->validator->make( $this->data, $setOfRules );
51
+            if (is_string($setOfRules) && method_exists($this, $setOfRules)) $validator = $this->validator->make($this->data, $this->{$setOfRules}());
52
+            else if (is_array($setOfRules)) $validator = $this->validator->make($this->data, $setOfRules);
53 53
             else
54 54
             {
55 55
                 throw new ValidationFunctionDoesNotExist();
56 56
             }
57 57
 
58
-            if ( !is_null( $validator ) )
58
+            if (!is_null($validator))
59 59
             {
60
-                if( !$validator->fails() ) return TRUE;
60
+                if (!$validator->fails()) return TRUE;
61 61
                 else $this->errors = $validator->messages()->getMessages();
62 62
             }
63 63
         }
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      * @param $key
80 80
      * @return mixed
81 81
      */
82
-    public function get( $key )
82
+    public function get($key)
83 83
     {
84
-        return @$this->data[ $key ];
84
+        return @$this->data[$key];
85 85
     }
86 86
 
87 87
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,17 +48,22 @@
 block discarded – undo
48 48
         if ( is_string( $setOfRules ) || is_array( $setOfRules ) )
49 49
         {
50 50
             $validator = NULL;
51
-            if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) $validator = $this->validator->make( $this->data, $this->{$setOfRules}() );
52
-            else if ( is_array( $setOfRules ) ) $validator = $this->validator->make( $this->data, $setOfRules );
53
-            else
51
+            if ( is_string( $setOfRules ) && method_exists( $this, $setOfRules ) ) {
52
+                $validator = $this->validator->make( $this->data, $this->{$setOfRules}() );
53
+            } else if ( is_array( $setOfRules ) ) {
54
+                $validator = $this->validator->make( $this->data, $setOfRules );
55
+            } else
54 56
             {
55 57
                 throw new ValidationFunctionDoesNotExist();
56 58
             }
57 59
 
58 60
             if ( !is_null( $validator ) )
59 61
             {
60
-                if( !$validator->fails() ) return TRUE;
61
-                else $this->errors = $validator->messages()->getMessages();
62
+                if( !$validator->fails() ) {
63
+                    return TRUE;
64
+                } else {
65
+                    $this->errors = $validator->messages()->getMessages();
66
+                }
62 67
             }
63 68
         }
64 69
 
Please login to merge, or discard this patch.
ValidationServiceProvider.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         // merge default config
33 33
         $this->mergeConfigFrom(
34
-            __DIR__.$this->configPath , 'validators'
34
+            __DIR__.$this->configPath, 'validators'
35 35
         );
36 36
 
37 37
         // Bind the validators.
@@ -48,45 +48,45 @@  discard block
 block discarded – undo
48 48
         try
49 49
         {
50 50
             // Load config parameters needed.
51
-            $validatorsBasePath = config( 'validators.validators_path' );
52
-            $baseNamespace = rtrim( config( 'validators.validator_interfaces_namespace' ), '\\' ) . '\\';
51
+            $validatorsBasePath = config('validators.validators_path');
52
+            $baseNamespace = rtrim(config('validators.validator_interfaces_namespace'), '\\').'\\';
53 53
 
54
-            $folders = scandir( $validatorsBasePath );
54
+            $folders = scandir($validatorsBasePath);
55 55
 
56 56
             // Remove the first 2 directories: "." and "..".
57
-            array_shift( $folders );
58
-            array_shift( $folders );
57
+            array_shift($folders);
58
+            array_shift($folders);
59 59
 
60
-            foreach( $folders as $folder )
60
+            foreach ($folders as $folder)
61 61
             {
62 62
                 $folderPath = $validatorsBasePath.'/'.$folder;
63 63
                 $currentInterfaceNamespace = $baseNamespace.$folder.'\\';
64 64
                 $currentImplementationNamespace = $currentInterfaceNamespace.'src';
65 65
 
66 66
                 // Scan files within the folder.
67
-                $validatorInterfacesInFolder = File::files( $folderPath );
67
+                $validatorInterfacesInFolder = File::files($folderPath);
68 68
 
69
-                foreach( $validatorInterfacesInFolder as $validatorInterface )
69
+                foreach ($validatorInterfacesInFolder as $validatorInterface)
70 70
                 {
71 71
                     // For each file find the Interface and the implementation and bind them together.
72
-                    $interfaceName = pathinfo( $validatorInterface, PATHINFO_FILENAME );
72
+                    $interfaceName = pathinfo($validatorInterface, PATHINFO_FILENAME);
73 73
 
74
-                    $commonName = str_replace( 'Interface', '', $interfaceName );
74
+                    $commonName = str_replace('Interface', '', $interfaceName);
75 75
                     $interfaceFullClassName = $currentInterfaceNamespace.$interfaceName;
76 76
 
77 77
                     $fullClassName = $currentImplementationNamespace.'\\'.$commonName;
78 78
 
79
-                    if ( class_exists( $fullClassName ) )
79
+                    if (class_exists($fullClassName))
80 80
                     {
81 81
                         // Bind the class.
82
-                        $this->app->bind( $interfaceFullClassName, function ( $app ) use ( $fullClassName )
82
+                        $this->app->bind($interfaceFullClassName, function($app) use ($fullClassName)
83 83
                         {
84
-                            return $app->make( $fullClassName );
84
+                            return $app->make($fullClassName);
85 85
                         });
86 86
                     }
87 87
                 }
88 88
             }
89
-        } catch( \Exception $e )
89
+        } catch (\Exception $e)
90 90
         {
91 91
             // Be quiet; Silence is golden.
92 92
         }
Please login to merge, or discard this patch.