Passed
Push — 1.0.0-dev ( 83bedf...ceb5d8 )
by nguereza
02:34
created
core/classes/cache/FileCache.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
 	         */
49 49
 	        if(is_object($logger)){
50 50
 	          $this->logger = $logger;
51
-	        }
52
-	        else{
51
+	        } else{
53 52
 	            $this->logger =& class_loader('Log', 'classes');
54 53
 	            $this->logger->setLogger('Library::FileCache');
55 54
 	        }
@@ -95,8 +94,7 @@  discard block
 block discarded – undo
95 94
 		        // Unlinking when the file was expired
96 95
 		        unlink($filePath);
97 96
 		        return false;
98
-		     }
99
-		     else{
97
+		     } else{
100 98
 		     	$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
101 99
 		     	return $data['data'];
102 100
 		     }
@@ -133,8 +131,7 @@  discard block
 block discarded – undo
133 131
 		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
134 132
 		    	fclose($handle);
135 133
 		    	return false;
136
-		    }
137
-		    else{
134
+		    } else{
138 135
 		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
139 136
 		    	fclose($handle);
140 137
 				chmod($filePath, 0640);
@@ -156,8 +153,7 @@  discard block
 block discarded – undo
156 153
 			if(! file_exists($filePath)){
157 154
 				$this->logger->info('This cache file does not exists skipping');
158 155
 				return false;
159
-			}
160
-			else{
156
+			} else{
161 157
 				$this->logger->info('Found cache file [' .$filePath. '] remove it');
162 158
 	      		unlink($filePath);
163 159
 				return true;
@@ -210,8 +206,7 @@  discard block
 block discarded – undo
210 206
 			$list = glob(CACHE_PATH . '*.cache');
211 207
 			if(! $list){
212 208
 				$this->logger->info('No cache files were found skipping');
213
-			}
214
-			else{
209
+			} else{
215 210
 				$this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
216 211
 				foreach ($list as $file) {
217 212
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -219,12 +214,10 @@  discard block
 block discarded – undo
219 214
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
220 215
 		      		if(! $data){
221 216
 		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
222
-		      		}
223
-		      		else if(time() > $data['expire']){
217
+		      		} else if(time() > $data['expire']){
224 218
 		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
225 219
 		      			unlink($file);
226
-		      		}
227
-		      		else{
220
+		      		} else{
228 221
 		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
229 222
 		      		}
230 223
 				}
@@ -239,8 +232,7 @@  discard block
 block discarded – undo
239 232
 			$list = glob(CACHE_PATH . '*.cache');
240 233
 			if(! $list){
241 234
 				$this->logger->info('No cache files were found skipping');
242
-			}
243
-			else{
235
+			} else{
244 236
 				$this->logger->info('Found [' . count($list) . '] cache files to remove');
245 237
 				foreach ($list as $file) {
246 238
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -267,8 +259,7 @@  discard block
 block discarded – undo
267 259
 				
268 260
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
269 261
 				$this->compressCacheData = false;
270
-			}
271
-			else{
262
+			} else{
272 263
 				$this->compressCacheData = $status;
273 264
 			}
274 265
 			return $this;
Please login to merge, or discard this patch.
core/classes/Router.php 1 patch
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -266,8 +266,7 @@  discard block
 block discarded – undo
266 266
 	    	//if the application is running in CLI mode use the first argument
267 267
 			else if(IS_CLI && isset($_SERVER['argv'][1])){
268 268
 				$routeUri = $_SERVER['argv'][1];
269
-			}
270
-			else if(isset($_SERVER['REQUEST_URI'])){
269
+			} else if(isset($_SERVER['REQUEST_URI'])){
271 270
 				$routeUri = $_SERVER['REQUEST_URI'];
272 271
 			}
273 272
 			$this->logger->debug('Check if URL suffix is enabled in the configuration');
@@ -363,15 +362,13 @@  discard block
 block discarded – undo
363 362
 				if(! class_exists($controller, false)){
364 363
 					$e404 = true;
365 364
 					$this->logger->warning('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
366
-				}
367
-				else{
365
+				} else{
368 366
 					$controllerInstance = new $controller();
369 367
 					$controllerMethod = $this->getMethod();
370 368
 					if(! method_exists($controllerInstance, $controllerMethod)){
371 369
 						$e404 = true;
372 370
 						$this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
373
-					}
374
-					else{
371
+					} else{
375 372
 						$this->logger->info('Routing data is set correctly now GO!');
376 373
 						call_user_func_array(array($controllerInstance, $controllerMethod), $this->args);
377 374
 						//render the final page to user
@@ -379,8 +376,7 @@  discard block
 block discarded – undo
379 376
 						get_instance()->response->renderFinalPage();
380 377
 					}
381 378
 				}
382
-			}
383
-			else{
379
+			} else{
384 380
 				$this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
385 381
 				$e404 = true;
386 382
 			}
@@ -486,8 +482,7 @@  discard block
 block discarded – undo
486 482
 						$this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']');
487 483
 						$this->module = $moduleControllerMethod[0];
488 484
 						$moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
489
-					}
490
-					else{
485
+					} else{
491 486
 						$this->logger->info('The current request does not use the module');
492 487
 						$moduleControllerMethod = explode('@', $this->callback[$index]);
493 488
 					}
@@ -543,8 +538,7 @@  discard block
 block discarded – undo
543 538
 					}
544 539
 					//args
545 540
 					$this->args = $segment;
546
-				}
547
-				else{
541
+				} else{
548 542
 					$this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
549 543
 					if(in_array($segment[0], $modules)){
550 544
 						$this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
@@ -558,8 +552,7 @@  discard block
 block discarded – undo
558 552
 							if(! $path){
559 553
 								$this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller');
560 554
 								$this->controller = $this->module;
561
-							}
562
-							else{
555
+							} else{
563 556
 								$this->controllerPath = $path;
564 557
 								array_shift($segment);
565 558
 							}
@@ -571,8 +564,7 @@  discard block
 block discarded – undo
571 564
 						}
572 565
 						//the remaining is for args
573 566
 						$this->args = $segment;
574
-					}
575
-					else{
567
+					} else{
576 568
 						$this->logger->info('The current request information is not found in the module list');
577 569
 						//controller
578 570
 						if(isset($segment[0])){
@@ -615,8 +607,7 @@  discard block
 block discarded – undo
615 607
 	    protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){
616 608
 	      if ($logger !== null){
617 609
 	        $this->logger = $logger;
618
-	      }
619
-	      else{
610
+	      } else{
620 611
 	          $this->logger =& class_loader('Log', 'classes');
621 612
 	          $this->logger->setLogger('Library::Router');
622 613
 	      }
Please login to merge, or discard this patch.
core/classes/Security.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 60
 			if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){
61 61
 				$logger->info('The CSRF token not yet expire just return it');
62 62
 				return Session::get($key);
63
-			}
64
-			else{
63
+			} else{
65 64
 				$newTime = $currentTime + $expire;
66 65
 				$token = sha1(uniqid()) . sha1(uniqid());
67 66
 				$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']');
@@ -123,8 +122,7 @@  discard block
 block discarded – undo
123 122
 						$logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
124 123
 						//wildcard to access all ip address
125 124
 						return;
126
-					}
127
-					else{
125
+					} else{
128 126
 						// go through all whitelisted ips
129 127
 						foreach ($list as $ipaddr) {
130 128
 							// find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
@@ -149,8 +147,7 @@  discard block
 block discarded – undo
149 147
 						show_error('Access to this application is not allowed');
150 148
 					}
151 149
 				}
152
-			}
153
-			else{
150
+			} else{
154 151
 				$logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
155 152
 			}
156 153
 		 }
Please login to merge, or discard this patch.
core/classes/Response.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -158,8 +158,7 @@  discard block
 block discarded – undo
158 158
 			if(! headers_sent()){
159 159
 				header('Location: '.$url);
160 160
 				exit;
161
-			}
162
-			else{
161
+			} else{
163 162
 				echo '<script>
164 163
 						location.href = "'.$url.'";
165 164
 					</script>';
@@ -208,12 +207,10 @@  discard block
 block discarded – undo
208 207
 					if($moduleViewPath){
209 208
 						$path = $moduleViewPath;
210 209
 						$logger->info('Found view [' . $view . '] in module [' .$mod. '], the file path is [' .$moduleViewPath. '] we will used it');
211
-					}
212
-					else{
210
+					} else{
213 211
 						$logger->info('Cannot find view [' . $view . '] in module [' .$mod. '] using the default location');
214 212
 					}
215
-				}
216
-				else{
213
+				} else{
217 214
 					$logger->info('The current request does not use module using the default location.');
218 215
 				}
219 216
 			}
@@ -358,8 +355,7 @@  discard block
 block discarded – undo
358 355
 					echo $content;
359 356
 					ob_end_flush();
360 357
 					return;
361
-				}
362
-				else{
358
+				} else{
363 359
 					$logger->info('The page cache content for the URL [' . $url . '] is not valid may be already expired');
364 360
 					$cache->delete($pageCacheKey);
365 361
 				}
@@ -407,8 +403,7 @@  discard block
 block discarded – undo
407 403
 				$output = ob_get_clean();
408 404
 				self::sendHeaders(404);
409 405
 				echo $output;
410
-			}
411
-			else{
406
+			} else{
412 407
 				show_error('The 404 view [' .$path. '] does not exist');
413 408
 			}
414 409
 		}
@@ -431,8 +426,7 @@  discard block
 block discarded – undo
431 426
 				$output = ob_get_clean();
432 427
 				self::sendHeaders(503);
433 428
 				echo $output;
434
-			}
435
-			else{
429
+			} else{
436 430
 				//can't use show_error() at this time because some dependencies not yet loaded and to prevent loop
437 431
 				set_http_status_header(503);
438 432
 				echo 'The error view [' . $path . '] does not exist';
Please login to merge, or discard this patch.
core/libraries/Pagination.php 1 patch
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
                 require_once CONFIG_PATH . 'config_pagination.php';
49 49
                 if (empty($config) || ! is_array($config)){
50 50
                     show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php');
51
-                }
52
-				else{
51
+                } else{
53 52
 					if (! empty($overwriteConfig)){
54 53
 						$config = array_merge($config, $overwriteConfig);
55 54
 					}
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
 					Config::setAll($config);
59 58
 					unset($config);
60 59
 				}
61
-            }
62
-            else{
60
+            } else{
63 61
                 show_error('Unable to find the pagination configuration file');
64 62
             }
65 63
         }
@@ -119,18 +117,15 @@  discard block
 block discarded – undo
119 117
             $query = '';
120 118
              if ($queryString == ''){
121 119
                 $query = '?' . $pageQueryName . '=';
122
-            }
123
-            else{
120
+            } else{
124 121
                 $tab = explode($pageQueryName . '=', $queryString);
125 122
                 $nb = count($tab);
126 123
                 if ($nb == 1){
127 124
                     $query = '?' . $queryString . '&' . $pageQueryName . '=';
128
-                }
129
-                else{
125
+                } else{
130 126
                     if ($tab[0] == ''){
131 127
                         $query = '?' . $pageQueryName . '=';
132
-                    }
133
-                    else{
128
+                    } else{
134 129
                         $query = '?' . $tab[0] . '' . $pageQueryName . '=';
135 130
                     }
136 131
                 }
@@ -175,20 +170,17 @@  discard block
 block discarded – undo
175 170
             if ($numberOfLink % 2 == 0){
176 171
                 $start = $currentPageNumber - ($numberOfLink / 2) + 1;
177 172
                 $end = $currentPageNumber + ($numberOfLink / 2);
178
-            }
179
-            else{
173
+            } else{
180 174
                 $start = $currentPageNumber - floor($numberOfLink / 2);
181 175
                 $end = $currentPageNumber + floor($numberOfLink / 2);
182 176
             }
183 177
             if ($start <= 1){
184 178
                 $begin = 1;
185 179
                 $end = $numberOfLink;
186
-            }
187
-            else if ($start > 1 && $end < $numberOfPage){
180
+            } else if ($start > 1 && $end < $numberOfPage){
188 181
                 $begin = $start;
189 182
                 $end = $end;
190
-            }
191
-            else{
183
+            } else{
192 184
                 $begin = ($numberOfPage - $numberOfLink) + 1;
193 185
                 $end = $numberOfPage;
194 186
             }
@@ -204,8 +196,7 @@  discard block
 block discarded – undo
204 196
             ///////////
205 197
             else if ($currentPageNumber > 1 && $currentPageNumber < $numberOfPage){
206 198
                 $navbar .= $this->buildPaginationLinkForMiddlePage($begin, $end, $currentPageNumber);
207
-            }
208
-            else if ($currentPageNumber == $numberOfPage){
199
+            } else if ($currentPageNumber == $numberOfPage){
209 200
                $navbar .= $this->buildPaginationLinkForLastPage($begin, $end, $currentPageNumber);
210 201
             }
211 202
             $navbar = $this->config['pagination_open'] . $navbar . $this->config['pagination_close'];
@@ -225,8 +216,7 @@  discard block
 block discarded – undo
225 216
             for($i = $begin; $i <= $end; $i++){
226 217
                 if ($i == $currentPageNumber){
227 218
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
228
-                }
229
-                else{
219
+                } else{
230 220
                     $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '" ' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
231 221
                 }
232 222
             }
@@ -248,8 +238,7 @@  discard block
 block discarded – undo
248 238
             for($i = $begin; $i <= $end; $i++){
249 239
                 if ($i == $currentPageNumber){
250 240
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
251
-                }
252
-                else{
241
+                } else{
253 242
                     $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i .'</a>' . $this->config['digit_close'];
254 243
                 }
255 244
             }
@@ -271,8 +260,7 @@  discard block
 block discarded – undo
271 260
             for($i = $begin; $i <= $end; $i++){
272 261
                 if ($i == $currentPageNumber){
273 262
                     $navbar .= $this->config['active_link_open'] . $currentPageNumber . $this->config['active_link_close'];
274
-                }
275
-                else{
263
+                } else{
276 264
                     $navbar .= $this->config['digit_open'] . '<a href="' . $query . $i . '"' . attributes_to_string($this->config['attributes']) . '>' . $i . '</a>' . $this->config['digit_close'];
277 265
                 }
278 266
             }
Please login to merge, or discard this patch.