Passed
Push — master ( 8005df...2d92e4 )
by Darío
03:27
created
test/Error/ErrorTraitTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
     public function getContentsFromUrl($filename)
127 127
     {
128 128
         $headers = get_headers($url);
129
-        $exists = stripos($headers[0],"200 OK") ? true : false;
129
+        $exists = stripos($headers[0], "200 OK") ? true : false;
130 130
 
131 131
         if ($exists)
132 132
             return file_get_contents($filename);
Please login to merge, or discard this patch.
Braces   +17 added lines, -16 removed lines patch added patch discarded remove patch
@@ -90,13 +90,11 @@  discard block
 block discarded – undo
90 90
         try
91 91
         {
92 92
             $ctrl->addNonExistingError();
93
-        }
94
-        catch (\Exception $e)
93
+        } catch (\Exception $e)
95 94
         {
96 95
             $errorObject = ($e instanceof \LogicException);
97 96
             $message = $e->getMessage();
98
-        }
99
-        finally
97
+        } finally
100 98
         {
101 99
             $this->assertTrue($errorObject, $message);
102 100
         }
@@ -109,18 +107,20 @@  discard block
 block discarded – undo
109 107
 
110 108
     public function getContentsFromFile($filename)
111 109
     {
112
-        if (file_exists($filename))
113
-            return file_get_contents($filename);
114
-        else
115
-            $this->error(Errno::FILE_NOT_FOUND, $filename);
110
+        if (file_exists($filename)) {
111
+                    return file_get_contents($filename);
112
+        } else {
113
+                    $this->error(Errno::FILE_NOT_FOUND, $filename);
114
+        }
116 115
     }
117 116
 
118 117
     public function getContentsFromFileWithoutFilenameOnError($filename)
119 118
     {
120
-        if (file_exists($filename))
121
-            return file_get_contents($filename);
122
-        else
123
-            $this->error(Errno::FILE_NOT_FOUND);
119
+        if (file_exists($filename)) {
120
+                    return file_get_contents($filename);
121
+        } else {
122
+                    $this->error(Errno::FILE_NOT_FOUND);
123
+        }
124 124
     }
125 125
 
126 126
     public function getContentsFromUrl($filename)
@@ -128,10 +128,11 @@  discard block
 block discarded – undo
128 128
         $headers = get_headers($url);
129 129
         $exists = stripos($headers[0],"200 OK") ? true : false;
130 130
 
131
-        if ($exists)
132
-            return file_get_contents($filename);
133
-        else
134
-            $this->error("URL not found");
131
+        if ($exists) {
132
+                    return file_get_contents($filename);
133
+        } else {
134
+                    $this->error("URL not found");
135
+        }
135 136
     }
136 137
 
137 138
     public function addNonExistingError()
Please login to merge, or discard this patch.
src/Error/ErrorTrait.php 1 patch
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -92,15 +92,16 @@  discard block
 block discarded – undo
92 92
      */
93 93
     protected function _error($code, $message = null)
94 94
     {
95
-        if (!is_null($code) && !is_integer($code))
96
-            throw new \InvalidArgumentException("Invalid type given. Integer expected");
95
+        if (!is_null($code) && !is_integer($code)) {
96
+                    throw new \InvalidArgumentException("Invalid type given. Integer expected");
97
+        }
97 98
 
98
-        if (is_null($code))
99
-            $code = preg_replace('/=|\/|\+/', "", base64_encode($message));
100
-        else
99
+        if (is_null($code)) {
100
+                    $code = preg_replace('/=|\/|\+/', "", base64_encode($message));
101
+        } else
101 102
         {
102
-            if (!array_key_exists($code, $this->standardErrors) && empty($message))
103
-                /*
103
+            if (!array_key_exists($code, $this->standardErrors) && empty($message)) {
104
+                            /*
104 105
                  * "This kind of exception should lead directly to a fix in your code"
105 106
                  * Non-standard errors must have a message to describe the error, make sure
106 107
                  * you execute the error() method with a message as the second parameter.
@@ -108,16 +109,18 @@  discard block
 block discarded – undo
108 109
                  * Ref: http://php.net/manual/en/class.logicexception.php
109 110
                  */
110 111
                 throw new \LogicException('The message does not be empty in non-standard errors!');
112
+            }
111 113
         }
112 114
 
113
-        if (!array_key_exists($code, $this->errors))
114
-            $this->errors[$code] = (array_key_exists($code, $this->standardErrors))
115
+        if (!array_key_exists($code, $this->errors)) {
116
+                    $this->errors[$code] = (array_key_exists($code, $this->standardErrors))
115 117
                 ?
116 118
                     is_null($message)
117 119
                         ? preg_replace('/\s\'%[a-zA-Z]*%\'/', $message, $this->standardErrors[$code])
118 120
                         # if $message is not null it will replace the %file% wildcard
119 121
                         : preg_replace('/%[a-zA-Z]*%/', $message, $this->standardErrors[$code])
120 122
                 : $message;
123
+        }
121 124
     }
122 125
 
123 126
     function __call($method, $arguments)
@@ -127,10 +130,11 @@  discard block
 block discarded – undo
127 130
             switch (count($arguments))
128 131
             {
129 132
                 case 1:
130
-                    if (is_integer($arguments[0]))
131
-                        return call_user_func([$this, '_error'], array_shift($arguments));
132
-                    else
133
-                        return call_user_func([$this, '_error'], null, array_shift($arguments));
133
+                    if (is_integer($arguments[0])) {
134
+                                            return call_user_func([$this, '_error'], array_shift($arguments));
135
+                    } else {
136
+                                            return call_user_func([$this, '_error'], null, array_shift($arguments));
137
+                    }
134 138
                     break;
135 139
                 case 2:
136 140
                     return call_user_func([$this, '_error'], $arguments[0], $arguments[1]);
Please login to merge, or discard this patch.