Completed
Push — master ( d9d608...2478d5 )
by Thierry
01:56
created
src/Code/Generator.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     private function getJsLibUri()
77 77
     {
78
-        if(!$this->hasOption('js.lib.uri'))
78
+        if (!$this->hasOption('js.lib.uri'))
79 79
         {
80 80
             // return 'https://cdn.jsdelivr.net/jaxon/1.2.0/';
81 81
             return 'https://cdn.jsdelivr.net/gh/jaxon-php/[email protected]/dist/';
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         // The jsDelivr CDN only hosts minified files
99 99
         // if(($this->getOption('js.app.minify')) || substr($this->getJsLibUri(), 0, $nLen) == $jsDelivrUri)
100 100
         // Starting from version 2.0.0 of the js lib, the jsDelivr CDN also hosts non minified files.
101
-        if(($this->getOption('js.app.minify')))
101
+        if (($this->getOption('js.app.minify')))
102 102
         {
103 103
             return '.min.js';
104 104
         }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         // Check config options
116 116
         // - The js.app.extern option must be set to true
117 117
         // - The js.app.uri and js.app.dir options must be set to non null values
118
-        if(!$this->getOption('js.app.extern') ||
118
+        if (!$this->getOption('js.app.extern') ||
119 119
             !$this->getOption('js.app.uri') ||
120 120
             !$this->getOption('js.app.dir'))
121 121
         {
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         // Check dir access
125 125
         // - The js.app.dir must be writable
126 126
         $sJsAppDir = $this->getOption('js.app.dir');
127
-        if(!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
127
+        if (!is_dir($sJsAppDir) || !is_writable($sJsAppDir))
128 128
         {
129 129
             return false;
130 130
         }
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      */
139 139
     private function setTemplateCacheDir()
140 140
     {
141
-        if($this->hasOption('core.template.cache_dir'))
141
+        if ($this->hasOption('core.template.cache_dir'))
142 142
         {
143 143
             $this->setCacheDir($this->getOption('core.template.cache_dir'));
144 144
         }
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
     private function generateHash()
153 153
     {
154 154
         $sHash = jaxon()->getVersion();
155
-        foreach($this->xPluginManager->getRequestPlugins() as $xPlugin)
155
+        foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin)
156 156
         {
157 157
             $sHash .= $xPlugin->generateHash();
158 158
         }
159
-        foreach($this->xPluginManager->getResponsePlugins() as $xPlugin)
159
+        foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin)
160 160
         {
161 161
             $sHash .= $xPlugin->generateHash();
162 162
         }
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
      */
171 171
     private function makePluginsCode()
172 172
     {
173
-        if($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null)
173
+        if ($this->sCssCode === null || $this->sJsCode === null || $this->sJsReady === null)
174 174
         {
175 175
             $this->sCssCode = '';
176 176
             $this->sJsCode = '';
177 177
             $this->sJsReady = '';
178
-            foreach($this->xPluginManager->getResponsePlugins() as $xPlugin)
178
+            foreach ($this->xPluginManager->getResponsePlugins() as $xPlugin)
179 179
             {
180
-                if(($str = trim($xPlugin->getCss())))
180
+                if (($str = trim($xPlugin->getCss())))
181 181
                 {
182 182
                     $this->sCssCode .= rtrim($str, " \n") . "\n";
183 183
                 }
184
-                if(($str = trim($xPlugin->getJs())))
184
+                if (($str = trim($xPlugin->getJs())))
185 185
                 {
186 186
                     $this->sJsCode .= rtrim($str, " \n") . "\n";
187 187
                 }
188
-                if(($str = trim($xPlugin->getScript())))
188
+                if (($str = trim($xPlugin->getScript())))
189 189
                 {
190 190
                     $this->sJsReady .= "\n" . trim($str, " \n");
191 191
                 }
192 192
             }
193 193
 
194 194
             $this->sJsReady = $this->render('jaxon::plugins/ready.js', ['sPluginScript' => $this->sJsReady]);
195
-            foreach($this->xPluginManager->getRequestPlugins() as $xPlugin)
195
+            foreach ($this->xPluginManager->getRequestPlugins() as $xPlugin)
196 196
             {
197
-                if(($str = trim($xPlugin->getScript())))
197
+                if (($str = trim($xPlugin->getScript())))
198 198
                 {
199 199
                     $this->sJsReady .= "\n" . trim($str, " \n");
200 200
                 }
201 201
             }
202 202
 
203
-            foreach($this->xPluginManager->getPackages() as $sClass)
203
+            foreach ($this->xPluginManager->getPackages() as $sClass)
204 204
             {
205 205
                 $xPackage = jaxon()->di()->get($sClass);
206
-                if(($str = trim($xPackage->css())))
206
+                if (($str = trim($xPackage->css())))
207 207
                 {
208 208
                     $this->sCssCode .= rtrim($str, " \n") . "\n";
209 209
                 }
210
-                if(($str = trim($xPackage->js())))
210
+                if (($str = trim($xPackage->js())))
211 211
                 {
212 212
                     $this->sJsCode .= rtrim($str, " \n") . "\n";
213 213
                 }
214 214
                 $xPackage = jaxon()->di()->get($sClass);
215
-                if(($str = trim($xPackage->ready())))
215
+                if (($str = trim($xPackage->ready())))
216 216
                 {
217 217
                     $this->sJsReady .= "\n" . trim($str, " \n");
218 218
                 }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
         // Add component files to the javascript file array;
238 238
         $aJsFiles = array($sJsCoreUrl);
239
-        if($this->getOption('core.debug.on'))
239
+        if ($this->getOption('core.debug.on'))
240 240
         {
241 241
             $aJsFiles[] = $sJsDebugUrl;
242 242
             $aJsFiles[] = $sJsLanguageUrl;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $this->setTemplateCacheDir();
332 332
         $this->makePluginsCode();
333 333
 
334
-        if($this->canExportJavascript())
334
+        if ($this->canExportJavascript())
335 335
         {
336 336
             $sJsAppURI = rtrim($this->getOption('js.app.uri'), '/') . '/';
337 337
             $sJsAppDir = rtrim($this->getOption('js.app.dir'), '/') . '/';
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
             $sHash = $this->generateHash();
341 341
             $sOutFile = $sHash . '.js';
342 342
             $sMinFile = $sHash . '.min.js';
343
-            if(!is_file($sJsAppDir . $sOutFile))
343
+            if (!is_file($sJsAppDir . $sOutFile))
344 344
             {
345 345
                 file_put_contents($sJsAppDir . $sOutFile, $this->_getScript());
346 346
             }
347
-            if(($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile))
347
+            if (($this->getOption('js.app.minify')) && !is_file($sJsAppDir . $sMinFile))
348 348
             {
349
-                if(($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
349
+                if (($this->minify($sJsAppDir . $sOutFile, $sJsAppDir . $sMinFile)))
350 350
                 {
351 351
                     $sOutFile = $sMinFile;
352 352
                 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -357,8 +357,7 @@
 block discarded – undo
357 357
                 'sJsOptions' => $this->getOption('js.app.options'),
358 358
                 'sUrl' => $sJsAppURI . $sOutFile,
359 359
             ));
360
-        }
361
-        else
360
+        } else
362 361
         {
363 362
             // The plugins scripts are wrapped with javascript tags
364 363
             $sScript = $this->render('jaxon::plugins/wrapper.js', array(
Please login to merge, or discard this patch.
src/Request/Plugin/CallableClass.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $this->xRepository = $xRepository;
62 62
 
63
-        if(!empty($_GET['jxncls']))
63
+        if (!empty($_GET['jxncls']))
64 64
         {
65 65
             $this->sRequestedClass = $_GET['jxncls'];
66 66
         }
67
-        if(!empty($_GET['jxnmthd']))
67
+        if (!empty($_GET['jxnmthd']))
68 68
         {
69 69
             $this->sRequestedMethod = $_GET['jxnmthd'];
70 70
         }
71
-        if(!empty($_POST['jxncls']))
71
+        if (!empty($_POST['jxncls']))
72 72
         {
73 73
             $this->sRequestedClass = $_POST['jxncls'];
74 74
         }
75
-        if(!empty($_POST['jxnmthd']))
75
+        if (!empty($_POST['jxnmthd']))
76 76
         {
77 77
             $this->sRequestedMethod = $_POST['jxnmthd'];
78 78
         }
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public function register($sType, $sClassName, $aOptions)
101 101
     {
102
-        if($sType != $this->getName())
102
+        if ($sType != $this->getName())
103 103
         {
104 104
             return false;
105 105
         }
106 106
 
107
-        if(!is_string($sClassName))
107
+        if (!is_string($sClassName))
108 108
         {
109 109
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
110 110
         }
111
-        if(is_string($aOptions))
111
+        if (is_string($aOptions))
112 112
         {
113 113
             $aOptions = ['include' => $aOptions];
114 114
         }
115
-        if(!is_array($aOptions))
115
+        if (!is_array($aOptions))
116 116
         {
117 117
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
118 118
         }
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
     public function canProcessRequest()
151 151
     {
152 152
         // Check the validity of the class name
153
-        if($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass))
153
+        if ($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass))
154 154
         {
155 155
             $this->sRequestedClass = null;
156 156
             $this->sRequestedMethod = null;
157 157
         }
158 158
         // Check the validity of the method name
159
-        if($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod))
159
+        if ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod))
160 160
         {
161 161
             $this->sRequestedClass = null;
162 162
             $this->sRequestedMethod = null;
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function processRequest()
173 173
     {
174
-        if(!$this->canProcessRequest())
174
+        if (!$this->canProcessRequest())
175 175
         {
176 176
             return false;
177 177
         }
178 178
 
179 179
         // Find the requested method
180 180
         $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass);
181
-        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
181
+        if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
182 182
         {
183 183
             // Unable to find the requested object or method
184 184
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         $jaxon = jaxon();
190 190
         $aArgs = $jaxon->getRequestHandler()->processArguments();
191 191
         $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs);
192
-        if(($xResponse))
192
+        if (($xResponse))
193 193
         {
194 194
             $jaxon->getResponseManager()->append($xResponse);
195 195
         }
Please login to merge, or discard this patch.
src/Plugin/Manager.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -132,32 +132,32 @@  discard block
 block discarded – undo
132 132
     {
133 133
         $bIsAlert = ($xPlugin instanceof \Jaxon\Dialog\Interfaces\Alert);
134 134
         $bIsConfirm = ($xPlugin instanceof \Jaxon\Dialog\Interfaces\Confirm);
135
-        if($xPlugin instanceof Request)
135
+        if ($xPlugin instanceof Request)
136 136
         {
137 137
             // The name of a request plugin is used as key in the plugin table
138 138
             $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin;
139 139
         }
140
-        elseif($xPlugin instanceof Response)
140
+        elseif ($xPlugin instanceof Response)
141 141
         {
142 142
             // The name of a response plugin is used as key in the plugin table
143 143
             $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin;
144 144
         }
145
-        elseif(!$bIsConfirm && !$bIsAlert)
145
+        elseif (!$bIsConfirm && !$bIsAlert)
146 146
         {
147 147
             throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', ['name' => get_class($xPlugin)]));
148 148
         }
149 149
         // This plugin implements the Alert interface
150
-        if($bIsAlert)
150
+        if ($bIsAlert)
151 151
         {
152 152
             jaxon()->dialog()->setAlert($xPlugin);
153 153
         }
154 154
         // This plugin implements the Confirm interface
155
-        if($bIsConfirm)
155
+        if ($bIsConfirm)
156 156
         {
157 157
             jaxon()->dialog()->setConfirm($xPlugin);
158 158
         }
159 159
         // Register the plugin as an event listener
160
-        if($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener)
160
+        if ($xPlugin instanceof \Jaxon\Utils\Interfaces\EventListener)
161 161
         {
162 162
             $this->addEventListener($xPlugin);
163 163
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function register($sType, $sCallable, $aOptions = [])
194 194
     {
195
-        if(!key_exists($sType, $this->aRequestPlugins))
195
+        if (!key_exists($sType, $this->aRequestPlugins))
196 196
         {
197 197
             throw new \Jaxon\Exception\Error($this->trans('errors.register.plugin', ['name' => $sType]));
198 198
         }
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
     {
221 221
         // Register user functions
222 222
         $aFunctionsConfig = $xAppConfig->getOption('functions', []);
223
-        foreach($aFunctionsConfig as $xKey => $xValue)
223
+        foreach ($aFunctionsConfig as $xKey => $xValue)
224 224
         {
225
-            if(is_integer($xKey) && is_string($xValue))
225
+            if (is_integer($xKey) && is_string($xValue))
226 226
             {
227 227
                 $sFunction = $xValue;
228 228
                 // Register a function without options
229 229
                 $this->register(Jaxon::USER_FUNCTION, $sFunction);
230 230
             }
231
-            elseif(is_string($xKey) && is_array($xValue))
231
+            elseif (is_string($xKey) && is_array($xValue))
232 232
             {
233 233
                 $sFunction = $xKey;
234 234
                 $aOptions = $xValue;
@@ -244,25 +244,25 @@  discard block
 block discarded – undo
244 244
 
245 245
         // Register classes and directories
246 246
         $aClassesConfig = $xAppConfig->getOption('classes', []);
247
-        foreach($aClassesConfig as $xKey => $xValue)
247
+        foreach ($aClassesConfig as $xKey => $xValue)
248 248
         {
249
-            if(is_integer($xKey) && is_string($xValue))
249
+            if (is_integer($xKey) && is_string($xValue))
250 250
             {
251 251
                 $sClass = $xValue;
252 252
                 // Register a class without options
253 253
                 $this->register(Jaxon::CALLABLE_CLASS, $sClass);
254 254
             }
255
-            elseif(is_string($xKey) && is_array($xValue))
255
+            elseif (is_string($xKey) && is_array($xValue))
256 256
             {
257 257
                 $sClass = $xKey;
258 258
                 $aOptions = $xValue;
259 259
                 // Register a class with options
260 260
                 $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions);
261 261
             }
262
-            elseif(is_integer($xKey) && is_array($xValue))
262
+            elseif (is_integer($xKey) && is_array($xValue))
263 263
             {
264 264
                 // The directory path is required
265
-                if(!key_exists('directory', $xValue))
265
+                if (!key_exists('directory', $xValue))
266 266
                 {
267 267
                     continue;
268 268
                     // Todo: throw an exception
@@ -270,17 +270,17 @@  discard block
 block discarded – undo
270 270
                 // Registering a directory
271 271
                 $sDirectory = $xValue['directory'];
272 272
                 $aOptions = [];
273
-                if(key_exists('options', $xValue) &&
273
+                if (key_exists('options', $xValue) &&
274 274
                     is_array($xValue['options']) || is_string($xValue['options']))
275 275
                 {
276 276
                     $aOptions = $xValue['options'];
277 277
                 }
278 278
                 // Setup directory options
279
-                if(key_exists('namespace', $xValue))
279
+                if (key_exists('namespace', $xValue))
280 280
                 {
281 281
                     $aOptions['namespace'] = $xValue['namespace'];
282 282
                 }
283
-                if(key_exists('separator', $xValue))
283
+                if (key_exists('separator', $xValue))
284 284
                 {
285 285
                     $aOptions['separator'] = $xValue['separator'];
286 286
                 }
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public function getResponsePlugin($sName)
307 307
     {
308
-        if(array_key_exists($sName, $this->aResponsePlugins))
308
+        if (array_key_exists($sName, $this->aResponsePlugins))
309 309
         {
310 310
             return $this->aResponsePlugins[$sName];
311 311
         }
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public function getRequestPlugin($sName)
323 323
     {
324
-        if(array_key_exists($sName, $this->aRequestPlugins))
324
+        if (array_key_exists($sName, $this->aRequestPlugins))
325 325
         {
326 326
             return $this->aRequestPlugins[$sName];
327 327
         }
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -136,13 +136,11 @@  discard block
 block discarded – undo
136 136
         {
137 137
             // The name of a request plugin is used as key in the plugin table
138 138
             $this->aRequestPlugins[$xPlugin->getName()] = $xPlugin;
139
-        }
140
-        elseif($xPlugin instanceof Response)
139
+        } elseif($xPlugin instanceof Response)
141 140
         {
142 141
             // The name of a response plugin is used as key in the plugin table
143 142
             $this->aResponsePlugins[$xPlugin->getName()] = $xPlugin;
144
-        }
145
-        elseif(!$bIsConfirm && !$bIsAlert)
143
+        } elseif(!$bIsConfirm && !$bIsAlert)
146 144
         {
147 145
             throw new \Jaxon\Exception\Error($this->trans('errors.register.invalid', ['name' => get_class($xPlugin)]));
148 146
         }
@@ -227,15 +225,13 @@  discard block
 block discarded – undo
227 225
                 $sFunction = $xValue;
228 226
                 // Register a function without options
229 227
                 $this->register(Jaxon::USER_FUNCTION, $sFunction);
230
-            }
231
-            elseif(is_string($xKey) && is_array($xValue))
228
+            } elseif(is_string($xKey) && is_array($xValue))
232 229
             {
233 230
                 $sFunction = $xKey;
234 231
                 $aOptions = $xValue;
235 232
                 // Register a function with options
236 233
                 $this->register(Jaxon::USER_FUNCTION, $sFunction, $aOptions);
237
-            }
238
-            else
234
+            } else
239 235
             {
240 236
                 continue;
241 237
                 // Todo: throw an exception
@@ -251,15 +247,13 @@  discard block
 block discarded – undo
251 247
                 $sClass = $xValue;
252 248
                 // Register a class without options
253 249
                 $this->register(Jaxon::CALLABLE_CLASS, $sClass);
254
-            }
255
-            elseif(is_string($xKey) && is_array($xValue))
250
+            } elseif(is_string($xKey) && is_array($xValue))
256 251
             {
257 252
                 $sClass = $xKey;
258 253
                 $aOptions = $xValue;
259 254
                 // Register a class with options
260 255
                 $this->register(Jaxon::CALLABLE_CLASS, $sClass, $aOptions);
261
-            }
262
-            elseif(is_integer($xKey) && is_array($xValue))
256
+            } elseif(is_integer($xKey) && is_array($xValue))
263 257
             {
264 258
                 // The directory path is required
265 259
                 if(!key_exists('directory', $xValue))
@@ -286,8 +280,7 @@  discard block
 block discarded – undo
286 280
                 }
287 281
                 // Register a class without options
288 282
                 $this->register(Jaxon::CALLABLE_DIR, $sDirectory, $aOptions);
289
-            }
290
-            else
283
+            } else
291 284
             {
292 285
                 continue;
293 286
                 // Todo: throw an exception
Please login to merge, or discard this patch.