Completed
Push — master ( f42a52...0a9499 )
by Thierry
02:50 queued 01:16
created
src/Utils/Dialogs/Alert.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
      */
26 26
     protected function alert($message)
27 27
     {
28
-        if($this->getReturn())
28
+        if ($this->getReturn())
29 29
         {
30 30
             return 'alert(' . $message . ')';
31 31
         }
Please login to merge, or discard this patch.
src/Response/Manager.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function append(ResponseContract $xResponse)
88 88
     {
89
-        if(!$this->xResponse)
89
+        if (!$this->xResponse)
90 90
         {
91 91
             $this->xResponse = $xResponse;
92 92
         }
93
-        elseif(get_class($this->xResponse) == get_class($xResponse))
93
+        elseif (get_class($this->xResponse) == get_class($xResponse))
94 94
         {
95
-            if($this->xResponse != $xResponse)
95
+            if ($this->xResponse != $xResponse)
96 96
             {
97 97
                 $this->xResponse->appendResponse($xResponse);
98 98
             }
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function printDebug()
141 141
     {
142
-        if(($this->xResponse))
142
+        if (($this->xResponse))
143 143
         {
144
-            foreach($this->aDebugMessages as $sMessage)
144
+            foreach ($this->aDebugMessages as $sMessage)
145 145
             {
146 146
                 $this->xResponse->debug($sMessage);
147 147
             }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function sendHeaders()
158 158
     {
159
-        if(($this->xResponse))
159
+        if (($this->xResponse))
160 160
         {
161 161
             $this->xResponse->sendHeaders();
162 162
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public function getOutput()
171 171
     {
172
-        if(($this->xResponse))
172
+        if (($this->xResponse))
173 173
         {
174 174
             return $this->xResponse->getOutput();
175 175
         }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function sendOutput()
185 185
     {
186
-        if(($this->xResponse))
186
+        if (($this->xResponse))
187 187
         {
188 188
             $this->xResponse->sendHeaders();
189 189
             $this->xResponse->printOutput();
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -89,15 +89,13 @@
 block discarded – undo
89 89
         if(!$this->xResponse)
90 90
         {
91 91
             $this->xResponse = $xResponse;
92
-        }
93
-        elseif(get_class($this->xResponse) == get_class($xResponse))
92
+        } elseif(get_class($this->xResponse) == get_class($xResponse))
94 93
         {
95 94
             if($this->xResponse != $xResponse)
96 95
             {
97 96
                 $this->xResponse->appendResponse($xResponse);
98 97
             }
99
-        }
100
-        else
98
+        } else
101 99
         {
102 100
             $this->debug($this->trans('errors.mismatch.types', ['class' => get_class($xResponse)]));
103 101
         }
Please login to merge, or discard this patch.
src/Plugin/CodeGenerator.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     private function getJsLibExt()
103 103
     {
104
-        if(($this->getOption('js.app.minify')))
104
+        if (($this->getOption('js.app.minify')))
105 105
         {
106 106
             return '.min.js';
107 107
         }
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         // Check config options
119 119
         // - The js.app.export option must be set to true
120 120
         // - The js.app.uri and js.app.dir options must be set to non null values
121
-        if(!$this->getOption('js.app.export') ||
121
+        if (!$this->getOption('js.app.export') ||
122 122
             !$this->getOption('js.app.uri') ||
123 123
             !$this->getOption('js.app.dir'))
124 124
         {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         // Check dir access
128 128
         // - The js.app.dir must be writable
129 129
         $sJsAppDir = $this->getOption('js.app.dir');
130
-        if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
130
+        if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
131 131
         {
132 132
             return false;
133 133
         }
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
     private function generateHash()
143 143
     {
144 144
         $sHash = jaxon()->getVersion();
145
-        foreach($this->xPluginManager->getRequestPlugins() as $xPlugin)
145
+        foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin)
146 146
         {
147 147
             $sHash .= $xPlugin->generateHash();
148 148
         }
149
-        foreach($this->xPluginManager->getResponsePlugins() as $xPlugin)
149
+        foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin)
150 150
         {
151 151
             $sHash .= $xPlugin->generateHash();
152 152
         }
@@ -160,22 +160,22 @@  discard block
 block discarded – undo
160 160
      */
161 161
     private function makePluginsCode()
162 162
     {
163
-        if($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null)
163
+        if ($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null)
164 164
         {
165 165
             $this->sCssCode = '';
166 166
             $this->sJsCode = '';
167 167
             $this->sJsReady = '';
168
-            foreach($this->xPluginManager->getResponsePlugins() as $xResponsePlugin)
168
+            foreach ($this->xPluginManager->getResponsePlugins() as $xResponsePlugin)
169 169
             {
170
-                if(($sCssCode = trim($xResponsePlugin->getCss())))
170
+                if (($sCssCode = trim($xResponsePlugin->getCss())))
171 171
                 {
172 172
                     $this->sCssCode .= rtrim($sCssCode, " \n") . "\n";
173 173
                 }
174
-                if(($sJsCode = trim($xResponsePlugin->getJs())))
174
+                if (($sJsCode = trim($xResponsePlugin->getJs())))
175 175
                 {
176 176
                     $this->sJsCode .= rtrim($sJsCode, " \n") . "\n";
177 177
                 }
178
-                if(($sJsReady = trim($xResponsePlugin->getScript())))
178
+                if (($sJsReady = trim($xResponsePlugin->getScript())))
179 179
                 {
180 180
                     $this->sJsReady .= trim($sJsReady, " \n") . "\n";
181 181
                 }
@@ -184,26 +184,26 @@  discard block
 block discarded – undo
184 184
             $this->sJsReady = $this->xTemplate->render('jaxon::plugins/ready.js', [
185 185
                 'sPluginScript' => $this->sJsReady,
186 186
             ]);
187
-            foreach($this->xPluginManager->getRequestPlugins() as $xRequestPlugin)
187
+            foreach ($this->xPluginManager->getRequestPlugins() as $xRequestPlugin)
188 188
             {
189
-                if(($sJsReady = trim($xRequestPlugin->getScript())))
189
+                if (($sJsReady = trim($xRequestPlugin->getScript())))
190 190
                 {
191 191
                     $this->sJsReady .= trim($sJsReady, " \n") . "\n";
192 192
                 }
193 193
             }
194 194
 
195
-            foreach($this->xPluginManager->getPackages() as $sPackageClass)
195
+            foreach ($this->xPluginManager->getPackages() as $sPackageClass)
196 196
             {
197 197
                 $xPackage = jaxon()->di()->get($sPackageClass);
198
-                if(($sCssCode = trim($xPackage->css())))
198
+                if (($sCssCode = trim($xPackage->css())))
199 199
                 {
200 200
                     $this->sCssCode .= rtrim($sCssCode, " \n") . "\n";
201 201
                 }
202
-                if(($sJsCode = trim($xPackage->js())))
202
+                if (($sJsCode = trim($xPackage->js())))
203 203
                 {
204 204
                     $this->sJsCode .= rtrim($sJsCode, " \n") . "\n";
205 205
                 }
206
-                if(($sJsReady = trim($xPackage->ready())))
206
+                if (($sJsReady = trim($xPackage->ready())))
207 207
                 {
208 208
                     $this->sJsReady .= trim($sJsReady, " \n") . "\n";
209 209
                 }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
         // Add component files to the javascript file array;
229 229
         $aJsFiles = [$sJsCoreUrl];
230
-        if($this->getOption('core.debug.on'))
230
+        if ($this->getOption('core.debug.on'))
231 231
         {
232 232
             $aJsFiles[] = $sJsDebugUrl;
233 233
             $aJsFiles[] = $sJsLanguageUrl;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public function getScript($bIncludeJs = false, $bIncludeCss = false)
323 323
     {
324
-        if(!$this->getOption('core.request.uri'))
324
+        if (!$this->getOption('core.request.uri'))
325 325
         {
326 326
             $this->setOption('core.request.uri', URI::detect());
327 327
         }
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
         $this->makePluginsCode();
331 331
 
332 332
         $sScript = '';
333
-        if(($bIncludeCss))
333
+        if (($bIncludeCss))
334 334
         {
335 335
             $sScript .= $this->getCss() . "\n";
336 336
         }
337
-        if(($bIncludeJs))
337
+        if (($bIncludeJs))
338 338
         {
339 339
             $sScript .= $this->getJs() . "\n";
340 340
         }
341 341
 
342
-        if($this->canExportJavascript())
342
+        if ($this->canExportJavascript())
343 343
         {
344 344
             $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/';
345 345
             $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/';
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
             $sExtension = $this->getJsLibExt();
348 348
 
349 349
             // Check if the final file already exists
350
-            if(($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension))
350
+            if (($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension))
351 351
             {
352 352
                 $sOutFile = $sFinalFile . $sExtension;
353 353
             }
@@ -357,25 +357,25 @@  discard block
 block discarded – undo
357 357
                 $sHash = $this->generateHash();
358 358
                 $sOutFile = $sHash . '.js';
359 359
                 $sMinFile = $sHash . '.min.js';
360
-                if(!is_file($sJsAppDir . $sOutFile))
360
+                if (!is_file($sJsAppDir . $sOutFile))
361 361
                 {
362 362
                     file_put_contents($sJsAppDir . $sOutFile, $this->_getScript());
363 363
                 }
364
-                if(($this->getOption('js.app.minify')))
364
+                if (($this->getOption('js.app.minify')))
365 365
                 {
366
-                    if(is_file($sJsAppDir . $sMinFile))
366
+                    if (is_file($sJsAppDir . $sMinFile))
367 367
                     {
368 368
                         $sOutFile = $sMinFile; // The file was already minified
369 369
                     }
370
-                    elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
370
+                    elseif (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
371 371
                     {
372 372
                         $sOutFile = $sMinFile;
373 373
                     }
374 374
                 }
375 375
                 // Copy the file to its final location
376
-                if(($sFinalFile))
376
+                if (($sFinalFile))
377 377
                 {
378
-                    if(copy($sJsAppDir . $sOutFile, $sJsAppDir . $sFinalFile . $sExtension))
378
+                    if (copy($sJsAppDir . $sOutFile, $sJsAppDir . $sFinalFile . $sExtension))
379 379
                     {
380 380
                         $sOutFile = $sFinalFile . $sExtension;
381 381
                     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -350,8 +350,7 @@  discard block
 block discarded – undo
350 350
             if(($sFinalFile) && is_file($sJsAppDir . $sFinalFile . $sExtension))
351 351
             {
352 352
                 $sOutFile = $sFinalFile . $sExtension;
353
-            }
354
-            else
353
+            } else
355 354
             {
356 355
                 // The plugins scripts are written into the javascript app dir
357 356
                 $sHash = $this->generateHash();
@@ -366,8 +365,7 @@  discard block
 block discarded – undo
366 365
                     if(is_file($sJsAppDir . $sMinFile))
367 366
                     {
368 367
                         $sOutFile = $sMinFile; // The file was already minified
369
-                    }
370
-                    elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
368
+                    } elseif(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
371 369
                     {
372 370
                         $sOutFile = $sMinFile;
373 371
                     }
@@ -387,8 +385,7 @@  discard block
 block discarded – undo
387 385
                 'sJsOptions' => $this->getOption('js.app.options', ''),
388 386
                 'sUrl' => $sJsAppURI . $sOutFile,
389 387
             ]);
390
-        }
391
-        else
388
+        } else
392 389
         {
393 390
             // The plugins scripts are wrapped with javascript tags
394 391
             $sScript .= $this->xTemplate->render('jaxon::plugins/wrapper.js', [
Please login to merge, or discard this patch.
src/CallableClass.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@
 block discarded – undo
94 94
         return jaxon()->instance($name);
95 95
     }
96 96
 
97
-   /**
97
+    /**
98 98
      * Get the uploaded files
99 99
      *
100 100
      * @return array
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@
 block discarded – undo
81 81
         $xCallableObject = jaxon()->di()->getCallableRepository()->getCallableObject(get_class($this));
82 82
         $cFirstChar = substr($name, 0, 1);
83 83
         // If the class name starts with a dot, then find the class in the same full namespace as the caller
84
-        if($cFirstChar == ':')
84
+        if ($cFirstChar == ':')
85 85
         {
86 86
             $name = $xCallableObject->getRootNamespace() . '\\' . str_replace('.', '\\', substr($name, 1));
87 87
         }
88 88
         // If the class name starts with a dot, then find the class in the same base namespace as the caller
89
-        elseif($cFirstChar == '.')
89
+        elseif ($cFirstChar == '.')
90 90
         {
91 91
             $name = $xCallableObject->getNamespace() . '\\' . str_replace('.', '\\', substr($name, 1));
92 92
         }
Please login to merge, or discard this patch.
src/Request/Factory/Parameter.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function make($xValue)
107 107
     {
108
-        if($xValue instanceof Contracts\Parameter)
108
+        if ($xValue instanceof Contracts\Parameter)
109 109
         {
110 110
             return $xValue;
111 111
         }
112
-        elseif(is_numeric($xValue))
112
+        elseif (is_numeric($xValue))
113 113
         {
114 114
             return new Parameter(self::NUMERIC_VALUE, $xValue);
115 115
         }
116
-        elseif(is_string($xValue))
116
+        elseif (is_string($xValue))
117 117
         {
118 118
             return new Parameter(self::QUOTED_VALUE, $xValue);
119 119
         }
120
-        elseif(is_bool($xValue))
120
+        elseif (is_bool($xValue))
121 121
         {
122 122
             return new Parameter(self::BOOL_VALUE, $xValue);
123 123
         }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     public function getScript()
162 162
     {
163 163
         $sJsCode = '';
164
-        switch($this->sType)
164
+        switch ($this->sType)
165 165
         {
166 166
         case self::FORM_VALUES:
167 167
             $sJsCode = $this->getJsCall('getFormValues', $this->xValue);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             $sJsCode = (string)$this->xValue;
189 189
             break;
190 190
         case self::JS_VALUE:
191
-            if(is_array($this->xValue) || is_object($this->xValue))
191
+            if (is_array($this->xValue) || is_object($this->xValue))
192 192
             {
193 193
                 // Unable to use double quotes here because they cannot be handled on client side.
194 194
                 // So we are using simple quotes even if the Json standard recommends double quotes.
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -108,20 +108,16 @@  discard block
 block discarded – undo
108 108
         if($xValue instanceof Contracts\Parameter)
109 109
         {
110 110
             return $xValue;
111
-        }
112
-        elseif(is_numeric($xValue))
111
+        } elseif(is_numeric($xValue))
113 112
         {
114 113
             return new Parameter(self::NUMERIC_VALUE, $xValue);
115
-        }
116
-        elseif(is_string($xValue))
114
+        } elseif(is_string($xValue))
117 115
         {
118 116
             return new Parameter(self::QUOTED_VALUE, $xValue);
119
-        }
120
-        elseif(is_bool($xValue))
117
+        } elseif(is_bool($xValue))
121 118
         {
122 119
             return new Parameter(self::BOOL_VALUE, $xValue);
123
-        }
124
-        else // if(is_array($xValue) || is_object($xValue))
120
+        } else // if(is_array($xValue) || is_object($xValue))
125 121
         {
126 122
             return new Parameter(self::JS_VALUE, $xValue);
127 123
         }
@@ -193,8 +189,7 @@  discard block
 block discarded – undo
193 189
                 // Unable to use double quotes here because they cannot be handled on client side.
194 190
                 // So we are using simple quotes even if the Json standard recommends double quotes.
195 191
                 $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT));
196
-            }
197
-            else
192
+            } else
198 193
             {
199 194
                 $sJsCode = (string)$this->xValue;
200 195
             }
Please login to merge, or discard this patch.
src/Request/Factory/JsCall.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -154,9 +154,9 @@
 block discarded – undo
154 154
      */
155 155
     public function addParameters(array $aParameters)
156 156
     {
157
-        foreach($aParameters as $xParameter)
157
+        foreach ($aParameters as $xParameter)
158 158
         {
159
-            if($xParameter instanceof JsCall)
159
+            if ($xParameter instanceof JsCall)
160 160
             {
161 161
                 $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}');
162 162
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -159,8 +159,7 @@
 block discarded – undo
159 159
             if($xParameter instanceof JsCall)
160 160
             {
161 161
                 $this->addParameter(Parameter::JS_VALUE, 'function(){' . $xParameter->getScript() . ';}');
162
-            }
163
-            else
162
+            } else
164 163
             {
165 164
                 $this->pushParameter(Parameter::make($xParameter));
166 165
             }
Please login to merge, or discard this patch.
src/Request/Support/CallableFunction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function configure($sName, $sValue)
86 86
     {
87
-        switch($sName)
87
+        switch ($sName)
88 88
         {
89 89
         case 'class': // The user function is a method in the given class
90 90
             $this->xCallableFunction = [$sValue, $this->xCallableFunction];
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function call($aArgs = [])
141 141
     {
142
-        if(($this->sInclude))
142
+        if (($this->sInclude))
143 143
         {
144 144
             require_once $this->sInclude;
145 145
         }
146 146
 
147 147
         // If the function is an alias for a class method, then instanciate the class
148
-        if(is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0]))
148
+        if (is_array($this->xCallableFunction) && is_string($this->xCallableFunction[0]))
149 149
         {
150 150
             $sClassName = $this->xCallableFunction[0];
151 151
             $this->xCallableFunction[0] = new $sClassName;
Please login to merge, or discard this patch.
src/Request/Support/CallableRepository.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         // Set the composer autoloader
86 86
         $sAutoloadFile = __DIR__ . '/../../../../../autoload.php';
87
-        if(file_exists($sAutoloadFile))
87
+        if (file_exists($sAutoloadFile))
88 88
         {
89 89
             $this->xAutoloader = require($sAutoloadFile);
90 90
         }
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
     private function getClassOptions($sClassName, array $aDirectoryOptions, array $aDefaultOptions = [])
116 116
     {
117 117
         $aOptions = $aDefaultOptions;
118
-        if(key_exists('separator', $aDirectoryOptions))
118
+        if (key_exists('separator', $aDirectoryOptions))
119 119
         {
120 120
             $aOptions['separator'] = $aDirectoryOptions['separator'];
121 121
         }
122
-        if(key_exists('protected', $aDirectoryOptions))
122
+        if (key_exists('protected', $aDirectoryOptions))
123 123
         {
124 124
             $aOptions['protected'] = $aDirectoryOptions['protected'];
125 125
         }
126
-        if(key_exists('*', $aDirectoryOptions))
126
+        if (key_exists('*', $aDirectoryOptions))
127 127
         {
128 128
             $aOptions = array_merge($aOptions, $aDirectoryOptions['*']);
129 129
         }
130
-        if(key_exists($sClassName, $aDirectoryOptions))
130
+        if (key_exists($sClassName, $aDirectoryOptions))
131 131
         {
132 132
             $aOptions = array_merge($aOptions, $aDirectoryOptions[$sClassName]);
133 133
         }
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
         $itDir = new RecursiveDirectoryIterator($sDirectory);
148 148
         $itFile = new RecursiveIteratorIterator($itDir);
149 149
         // Iterate on dir content
150
-        foreach($itFile as $xFile)
150
+        foreach ($itFile as $xFile)
151 151
         {
152 152
             // skip everything except PHP files
153
-            if(!$xFile->isFile() || $xFile->getExtension() != 'php')
153
+            if (!$xFile->isFile() || $xFile->getExtension() != 'php')
154 154
             {
155 155
                 continue;
156 156
             }
157 157
 
158 158
             $aClassOptions = [];
159 159
             // No more classmap autoloading. The file will be included when needed.
160
-            if(($aOptions['autoload']))
160
+            if (($aOptions['autoload']))
161 161
             {
162 162
                 $aClassOptions['include'] = $xFile->getPathname();
163 163
             }
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
     public function addNamespace($sNamespace, array $aOptions)
179 179
     {
180 180
         // Separator default value
181
-        if(!key_exists('separator', $aOptions))
181
+        if (!key_exists('separator', $aOptions))
182 182
         {
183 183
             $aOptions['separator'] = '.';
184 184
         }
185 185
         $aOptions['separator'] = trim($aOptions['separator']);
186
-        if(!in_array($aOptions['separator'], ['.', '_']))
186
+        if (!in_array($aOptions['separator'], ['.', '_']))
187 187
         {
188 188
             $aOptions['separator'] = '.';
189 189
         }
190
-        if($aOptions['separator'] == '_')
190
+        if ($aOptions['separator'] == '_')
191 191
         {
192 192
             $this->bUsingUnderscore = true;
193 193
         }
194 194
         // Set the autoload option default value
195
-        if(!key_exists('autoload', $aOptions))
195
+        if (!key_exists('autoload', $aOptions))
196 196
         {
197 197
             $aOptions['autoload'] = true;
198 198
         }
199 199
         // Register the dir with PSR4 autoloading
200
-        if(($aOptions['autoload']) && $this->xAutoloader != null)
200
+        if (($aOptions['autoload']) && $this->xAutoloader != null)
201 201
         {
202 202
             $this->xAutoloader->setPsr4($sNamespace . '\\', $aOptions['directory']);
203 203
         }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      */
215 215
     private function getOptionsFromClass($sClassName)
216 216
     {
217
-        if(!key_exists($sClassName, $this->aClassOptions))
217
+        if (!key_exists($sClassName, $this->aClassOptions))
218 218
         {
219 219
             return null; // Class not registered
220 220
         }
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
     private function getOptionsFromNamespace($sClassName, $sNamespace = null)
233 233
     {
234 234
         // Find the corresponding namespace
235
-        if($sNamespace === null)
235
+        if ($sNamespace === null)
236 236
         {
237
-            foreach(array_keys($this->aNamespaceOptions) as $_sNamespace)
237
+            foreach (array_keys($this->aNamespaceOptions) as $_sNamespace)
238 238
             {
239
-                if(substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\')
239
+                if (substr($sClassName, 0, strlen($_sNamespace) + 1) == $_sNamespace . '\\')
240 240
                 {
241 241
                     $sNamespace = $_sNamespace;
242 242
                     break;
243 243
                 }
244 244
             }
245 245
         }
246
-        if($sNamespace === null)
246
+        if ($sNamespace === null)
247 247
         {
248 248
             return null; // Class not registered
249 249
         }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         // Get the class options
252 252
         $aOptions = $this->aNamespaceOptions[$sNamespace];
253 253
         $aDefaultOptions = ['namespace' => $sNamespace];
254
-        if(key_exists('separator', $aOptions))
254
+        if (key_exists('separator', $aOptions))
255 255
         {
256 256
             $aDefaultOptions['separator'] = $aOptions['separator'];
257 257
         }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
     protected function _getCallableObject($sClassName, array $aOptions)
270 270
     {
271 271
         // Make sure the registered class exists
272
-        if(key_exists('include', $aOptions))
272
+        if (key_exists('include', $aOptions))
273 273
         {
274 274
             require_once($aOptions['include']);
275 275
         }
276
-        if(!class_exists($sClassName))
276
+        if (!class_exists($sClassName))
277 277
         {
278 278
             return null;
279 279
         }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
         // Create the callable object
282 282
         $xCallableObject = new CallableObject($sClassName);
283 283
         $this->aCallableOptions[$sClassName] = [];
284
-        foreach($aOptions as $sName => $xValue)
284
+        foreach ($aOptions as $sName => $xValue)
285 285
         {
286
-            if(in_array($sName, ['separator', 'namespace', 'protected']))
286
+            if (in_array($sName, ['separator', 'namespace', 'protected']))
287 287
             {
288 288
                 $xCallableObject->configure($sName, $xValue);
289 289
             }
290
-            elseif(is_array($xValue) && $sName != 'include')
290
+            elseif (is_array($xValue) && $sName != 'include')
291 291
             {
292 292
                 // These options are to be included in javascript code.
293 293
                 $this->aCallableOptions[$sClassName][$sName] = $xValue;
@@ -324,22 +324,22 @@  discard block
 block discarded – undo
324 324
         // at the beginning and the end of the class name.
325 325
         $sClassName = (string)$sClassName;
326 326
         $sClassName = trim(str_replace('.', '\\', $sClassName), '\\');
327
-        if($this->bUsingUnderscore)
327
+        if ($this->bUsingUnderscore)
328 328
         {
329 329
             $sClassName = trim(str_replace('_', '\\', $sClassName), '\\');
330 330
         }
331 331
 
332
-        if(key_exists($sClassName, $this->aCallableObjects))
332
+        if (key_exists($sClassName, $this->aCallableObjects))
333 333
         {
334 334
             return $this->aCallableObjects[$sClassName];
335 335
         }
336 336
 
337 337
         $aOptions = $this->getOptionsFromClass($sClassName);
338
-        if($aOptions === null)
338
+        if ($aOptions === null)
339 339
         {
340 340
             $aOptions = $this->getOptionsFromNamespace($sClassName);
341 341
         }
342
-        if($aOptions === null)
342
+        if ($aOptions === null)
343 343
         {
344 344
             return null;
345 345
         }
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
     public function createCallableObjects()
356 356
     {
357 357
         // Create callable objects for registered classes
358
-        foreach($this->aClassOptions as $sClassName => $aClassOptions)
358
+        foreach ($this->aClassOptions as $sClassName => $aClassOptions)
359 359
         {
360
-            if(!key_exists($sClassName, $this->aCallableObjects))
360
+            if (!key_exists($sClassName, $this->aCallableObjects))
361 361
             {
362 362
                 $this->_getCallableObject($sClassName, $aClassOptions);
363 363
             }
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 
366 366
         // Create callable objects for registered namespaces
367 367
         $sDS = DIRECTORY_SEPARATOR;
368
-        foreach($this->aNamespaceOptions as $sNamespace => $aOptions)
368
+        foreach ($this->aNamespaceOptions as $sNamespace => $aOptions)
369 369
         {
370
-            if(key_exists($sNamespace, $this->aNamespaces))
370
+            if (key_exists($sNamespace, $this->aNamespaces))
371 371
             {
372 372
                 continue;
373 373
             }
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
             $sDirectory = $aOptions['directory'];
379 379
             $itDir = new RecursiveDirectoryIterator($sDirectory);
380 380
             $itFile = new RecursiveIteratorIterator($itDir);
381
-            foreach($itFile as $xFile)
381
+            foreach ($itFile as $xFile)
382 382
             {
383 383
                 // skip everything except PHP files
384
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
384
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
385 385
                 {
386 386
                     continue;
387 387
                 }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 $sClassPath = $sNamespace;
391 391
                 $sRelativePath = substr($xFile->getPath(), strlen($sDirectory));
392 392
                 $sRelativePath = trim(str_replace($sDS, '\\', $sRelativePath), '\\');
393
-                if($sRelativePath != '')
393
+                if ($sRelativePath != '')
394 394
                 {
395 395
                     $sClassPath .= '\\' . $sRelativePath;
396 396
                 }
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
                 $this->aNamespaces[$sClassPath] = ['separator' => $aOptions['separator']];
399 399
                 $sClassName = $sClassPath . '\\' . $xFile->getBasename('.php');
400 400
 
401
-                if(!key_exists($sClassName, $this->aCallableObjects))
401
+                if (!key_exists($sClassName, $this->aCallableObjects))
402 402
                 {
403 403
                     $aClassOptions = $this->getOptionsFromNamespace($sClassName, $sNamespace);
404
-                    if($aClassOptions !== null)
404
+                    if ($aClassOptions !== null)
405 405
                     {
406 406
                         $this->_getCallableObject($sClassName, $aClassOptions);
407 407
                     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -286,8 +286,7 @@
 block discarded – undo
286 286
             if(in_array($sName, ['separator', 'namespace', 'protected']))
287 287
             {
288 288
                 $xCallableObject->configure($sName, $xValue);
289
-            }
290
-            elseif(is_array($xValue) && $sName != 'include')
289
+            } elseif(is_array($xValue) && $sName != 'include')
291 290
             {
292 291
                 // These options are to be included in javascript code.
293 292
                 $this->aCallableOptions[$sClassName][$sName] = $xValue;
Please login to merge, or discard this patch.
src/Request/Support/CallableObject.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -138,29 +138,29 @@  discard block
 block discarded – undo
138 138
      */
139 139
     public function configure($sName, $sValue)
140 140
     {
141
-        switch($sName)
141
+        switch ($sName)
142 142
         {
143 143
         // Set the separator
144 144
         case 'separator':
145
-            if($sValue == '_' || $sValue == '.')
145
+            if ($sValue == '_' || $sValue == '.')
146 146
             {
147 147
                 $this->sSeparator = $sValue;
148 148
             }
149 149
             break;
150 150
         // Set the namespace
151 151
         case 'namespace':
152
-            if(is_string($sValue))
152
+            if (is_string($sValue))
153 153
             {
154 154
                 $this->sNamespace = $sValue;
155 155
             }
156 156
             break;
157 157
         // Set the protected methods
158 158
         case 'protected':
159
-            if(is_array($sValue))
159
+            if (is_array($sValue))
160 160
             {
161 161
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
162 162
             }
163
-            elseif(is_string($sValue))
163
+            elseif (is_string($sValue))
164 164
             {
165 165
                 $this->aProtectedMethods[] = $sValue;
166 166
             }
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
     public function getMethods()
179 179
     {
180 180
         $aMethods = [];
181
-        foreach($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
181
+        foreach ($this->xReflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod)
182 182
         {
183 183
             $sMethodName = $xMethod->getShortName();
184 184
             // Don't take magic __call, __construct, __destruct methods
185
-            if(strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
185
+            if (strlen($sMethodName) > 2 && substr($sMethodName, 0, 2) == '__')
186 186
             {
187 187
                 continue;
188 188
             }
189 189
             // Don't take excluded methods
190
-            if(in_array($sMethodName, $this->aProtectedMethods))
190
+            if (in_array($sMethodName, $this->aProtectedMethods))
191 191
             {
192 192
                 continue;
193 193
             }
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function getRegisteredObject()
205 205
     {
206
-        if($this->xRegisteredObject == null)
206
+        if ($this->xRegisteredObject == null)
207 207
         {
208 208
             $di = jaxon()->di();
209 209
             // Use the Reflection class to get the parameters of the constructor
210
-            if(($constructor = $this->xReflectionClass->getConstructor()) != null)
210
+            if (($constructor = $this->xReflectionClass->getConstructor()) != null)
211 211
             {
212 212
                 $parameters = $constructor->getParameters();
213 213
                 $parameterInstances = [];
214
-                foreach($parameters as $parameter)
214
+                foreach ($parameters as $parameter)
215 215
                 {
216 216
                     // Get the parameter instance from the DI
217 217
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             }
225 225
 
226 226
             // Initialize the object
227
-            if($this->xRegisteredObject instanceof \Jaxon\CallableClass)
227
+            if ($this->xRegisteredObject instanceof \Jaxon\CallableClass)
228 228
             {
229 229
                 $this->xRegisteredObject->response = jaxon()->getResponse();
230 230
             }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function call($sMethod, $aArgs)
256 256
     {
257
-        if(!$this->hasMethod($sMethod))
257
+        if (!$this->hasMethod($sMethod))
258 258
         {
259 259
             return;
260 260
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,8 +159,7 @@  discard block
 block discarded – undo
159 159
             if(is_array($sValue))
160 160
             {
161 161
                 $this->aProtectedMethods = array_merge($this->aProtectedMethods, $sValue);
162
-            }
163
-            elseif(is_string($sValue))
162
+            } elseif(is_string($sValue))
164 163
             {
165 164
                 $this->aProtectedMethods[] = $sValue;
166 165
             }
@@ -217,8 +216,7 @@  discard block
 block discarded – undo
217 216
                     $parameterInstances[] = $di->get($parameter->getClass()->getName());
218 217
                 }
219 218
                 $this->xRegisteredObject = $this->xReflectionClass->newInstanceArgs($parameterInstances);
220
-            }
221
-            else
219
+            } else
222 220
             {
223 221
                 $this->xRegisteredObject = $this->xReflectionClass->newInstance();
224 222
             }
Please login to merge, or discard this patch.