Passed
Push — 1.0.0-dev ( c78053...5f99ee )
by nguereza
14:45
created
core/classes/Response.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Response{
27
+	class Response {
28 28
 
29 29
 		/**
30 30
 		 * The list of request header to send with response
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Construct new response instance
67 67
 		 */
68
-		public function __construct(){
69
-			$this->_currentUrl =  (! empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '' )
70
-					. (! empty($_SERVER['QUERY_STRING']) ? ('?' . $_SERVER['QUERY_STRING']) : '' );
68
+		public function __construct() {
69
+			$this->_currentUrl = (!empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')
70
+					. (!empty($_SERVER['QUERY_STRING']) ? ('?' . $_SERVER['QUERY_STRING']) : '');
71 71
 					
72 72
 			$this->_currentUrlCacheKey = md5($this->_currentUrl);
73 73
 			
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		 * Get the logger singleton instance
83 83
 		 * @return Log the logger instance
84 84
 		 */
85
-		private static function getLogger(){
86
-			if(self::$logger == null){
87
-				self::$logger[0] =& class_loader('Log', 'classes');
85
+		private static function getLogger() {
86
+			if (self::$logger == null) {
87
+				self::$logger[0] = & class_loader('Log', 'classes');
88 88
 				self::$logger[0]->setLogger('Library::Response');
89 89
 			}
90 90
 			return self::$logger[0];
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		 * @param  integer $httpCode the HTTP status code
96 96
 		 * @param  array   $headers   the additional headers to add to the existing headers list
97 97
 		 */
98
-		public static function sendHeaders($httpCode = 200, array $headers = array()){
98
+		public static function sendHeaders($httpCode = 200, array $headers = array()) {
99 99
 			set_http_status_header($httpCode);
100 100
 			self::setHeaders($headers);
101
-			if(! headers_sent()){
102
-				foreach(self::getHeaders() as $key => $value){
103
-					header($key .': '.$value);
101
+			if (!headers_sent()) {
102
+				foreach (self::getHeaders() as $key => $value) {
103
+					header($key . ': ' . $value);
104 104
 				}
105 105
 			}
106 106
 		}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * Get the list of the headers
110 110
 		 * @return array the headers list
111 111
 		 */
112
-		public static function getHeaders(){
112
+		public static function getHeaders() {
113 113
 			return self::$headers;
114 114
 		}
115 115
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		 * @param  string $name the header name
119 119
 		 * @return string       the header value
120 120
 		 */
121
-		public static function getHeader($name){
121
+		public static function getHeader($name) {
122 122
 			return array_key_exists($name, self::$headers) ? self::$headers[$name] : null;
123 123
 		}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		 * @param string $name  the header name
129 129
 		 * @param string $value the header value to be set
130 130
 		 */
131
-		public static function setHeader($name, $value){
131
+		public static function setHeader($name, $value) {
132 132
 			self::$headers[$name] = $value;
133 133
 		}
134 134
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		 * @param array $headers the list of the headers to set. 
138 138
 		 * Note: this will merge with the existing headers
139 139
 		 */
140
-		public static function setHeaders(array $headers){
140
+		public static function setHeaders(array $headers) {
141 141
 			self::$headers = array_merge(self::getHeaders(), $headers);
142 142
 		}
143 143
 		
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 		 * Redirect user in the specified page
146 146
 		 * @param  string $path the URL or URI to be redirect to
147 147
 		 */
148
-		public static function redirect($path = ''){
148
+		public static function redirect($path = '') {
149 149
 			$logger = self::getLogger();
150 150
 			$url = Url::site_url($path);
151
-			$logger->info('Redirect to URL [' .$url. ']');
152
-			if(! headers_sent()){
153
-				header('Location: '.$url);
151
+			$logger->info('Redirect to URL [' . $url . ']');
152
+			if (!headers_sent()) {
153
+				header('Location: ' . $url);
154 154
 				exit;
155 155
 			}
156
-			else{
156
+			else {
157 157
 				echo '<script>
158
-						location.href = "'.$url.'";
158
+						location.href = "'.$url . '";
159 159
 					</script>';
160 160
 			}
161 161
 		}
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 		 * @return void|string          if $return is true will return the view content otherwise
169 169
 		 * will display the view content.
170 170
 		 */
171
-		public function render($view, $data = null, $return = false){
171
+		public function render($view, $data = null, $return = false) {
172 172
 			$logger = self::getLogger();
173 173
 			//convert data to an array
174
-			$data = ! is_array($data) ? (array) $data : $data;
174
+			$data = !is_array($data) ? (array) $data : $data;
175 175
 			$view = str_ireplace('.php', '', $view);
176 176
 			$view = trim($view, '/\\');
177 177
 			$viewFile = $view . '.php';
@@ -180,42 +180,42 @@  discard block
 block discarded – undo
180 180
 			//super instance
181 181
 			$obj = & get_instance();
182 182
 			
183
-			if(Module::hasModule()){
183
+			if (Module::hasModule()) {
184 184
 				//check in module first
185 185
 				$logger->debug('Checking the view [' . $view . '] from module list ...');
186 186
 				$mod = null;
187 187
 				//check if the request class contains module name
188
-				if(strpos($view, '/') !== false){
188
+				if (strpos($view, '/') !== false) {
189 189
 					$viewPath = explode('/', $view);
190
-					if(isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())){
190
+					if (isset($viewPath[0]) && in_array($viewPath[0], Module::getModuleList())) {
191 191
 						$mod = $viewPath[0];
192 192
 						array_shift($viewPath);
193 193
 						$view = implode('/', $viewPath);
194 194
 						$viewFile = $view . '.php';
195 195
 					}
196 196
 				}
197
-				if(! $mod && !empty($obj->moduleName)){
197
+				if (!$mod && !empty($obj->moduleName)) {
198 198
 					$mod = $obj->moduleName;
199 199
 				}
200
-				if($mod){
200
+				if ($mod) {
201 201
 					$moduleViewPath = Module::findViewFullPath($view, $mod);
202
-					if($moduleViewPath){
202
+					if ($moduleViewPath) {
203 203
 						$path = $moduleViewPath;
204
-						$logger->info('Found view [' . $view . '] in module [' .$mod. '], the file path is [' .$moduleViewPath. '] we will used it');
204
+						$logger->info('Found view [' . $view . '] in module [' . $mod . '], the file path is [' . $moduleViewPath . '] we will used it');
205 205
 					}
206
-					else{
207
-						$logger->info('Cannot find view [' . $view . '] in module [' .$mod. '] using the default location');
206
+					else {
207
+						$logger->info('Cannot find view [' . $view . '] in module [' . $mod . '] using the default location');
208 208
 					}
209 209
 				}
210
-				else{
210
+				else {
211 211
 					$logger->info('The current request does not use module using the default location.');
212 212
 				}
213 213
 			}
214 214
 			$logger->info('The view file path to be loaded is [' . $path . ']');
215 215
 			$found = false;
216
-			if(file_exists($path)){
217
-				foreach(get_object_vars($obj) as $key => $value){
218
-					if(! isset($this->{$key})){
216
+			if (file_exists($path)) {
217
+				foreach (get_object_vars($obj) as $key => $value) {
218
+					if (!isset($this->{$key})) {
219 219
 						$this->{$key} = & $obj->{$key};
220 220
 					}
221 221
 				}
@@ -224,39 +224,39 @@  discard block
 block discarded – undo
224 224
 				//need use require() instead of require_once because can load this view many time
225 225
 				require $path;
226 226
 				$content = ob_get_clean();
227
-				if($return){
227
+				if ($return) {
228 228
 					return $content;
229 229
 				}
230 230
 				$this->_pageRender .= $content;
231 231
 				$found = true;
232 232
 			}
233
-			if(! $found){
234
-				show_error('Unable to find view [' .$view . ']');
233
+			if (!$found) {
234
+				show_error('Unable to find view [' . $view . ']');
235 235
 			}
236 236
 		}
237 237
 		
238 238
 		/**
239 239
 		* Send the final page output to user
240 240
 		*/
241
-		public function renderFinalPage(){
241
+		public function renderFinalPage() {
242 242
 			$logger = self::getLogger();
243 243
 			$obj = & get_instance();
244 244
 			$cachePageStatus = get_config('cache_enable', false) && !empty($obj->view_cache_enable);
245 245
 			$dispatcher = $obj->eventdispatcher;
246 246
 			$content = $this->_pageRender;
247
-			if(! $content){
247
+			if (!$content) {
248 248
 				$logger->warning('The final view content is empty.');
249 249
 				return;
250 250
 			}
251 251
 			//dispatch
252 252
 			$event = $dispatcher->dispatch(new EventInfo('FINAL_VIEW_READY', $content, true));
253
-			$content = ! empty($event->payload) ? $event->payload : null;
254
-			if(empty($content)){
253
+			$content = !empty($event->payload) ? $event->payload : null;
254
+			if (empty($content)) {
255 255
 				$logger->warning('The view content is empty after dispatch to event listeners.');
256 256
 			}
257 257
 			
258 258
 			//check whether need save the page into cache.
259
-			if($cachePageStatus){
259
+			if ($cachePageStatus) {
260 260
 				//current page URL
261 261
 				$url = $this->_currentUrl;
262 262
 				//Cache view Time to live in second
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 				
272 272
 				//get the cache information to prepare header to send to browser
273 273
 				$cacheInfo = $cacheInstance->getInfo($cacheKey);
274
-				if($cacheInfo){
274
+				if ($cacheInfo) {
275 275
 					$lastModified = $cacheInfo['mtime'];
276 276
 					$expire = $cacheInfo['expire'];
277 277
 					$maxAge = $expire - time();
278 278
 					self::setHeader('Pragma', 'public');
279 279
 					self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
280
-					self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
281
-					self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');	
280
+					self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
281
+					self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');	
282 282
 				}
283 283
 			}
284 284
 			
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 			$content = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsedTime, $memoryUsage), $content);
290 290
 			
291 291
 			//compress the output if is available
292
-			if (self::$_canCompressOutput){
292
+			if (self::$_canCompressOutput) {
293 293
 				ob_start('ob_gzhandler');
294 294
 			}
295
-			else{
295
+			else {
296 296
 				ob_start();
297 297
 			}
298 298
 			self::sendHeaders(200);
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		/**
304 304
 		* Send the final page output to user if is cached
305 305
 		*/
306
-		public function renderFinalPageFromCache(&$cache){
306
+		public function renderFinalPageFromCache(&$cache) {
307 307
 			$logger = self::getLogger();
308 308
 			$url = $this->_currentUrl;					
309 309
 			//the current page cache key for identification
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
 			$logger->debug('Checking if the page content for the URL [' . $url . '] is cached ...');
313 313
 			//get the cache information to prepare header to send to browser
314 314
 			$cacheInfo = $cache->getInfo($pageCacheKey);
315
-			if($cacheInfo){
315
+			if ($cacheInfo) {
316 316
 				$lastModified = $cacheInfo['mtime'];
317 317
 				$expire = $cacheInfo['expire'];
318 318
 				$maxAge = $expire - $_SERVER['REQUEST_TIME'];
319 319
 				self::setHeader('Pragma', 'public');
320 320
 				self::setHeader('Cache-Control', 'max-age=' . $maxAge . ', public');
321
-				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire).' GMT');
322
-				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified).' GMT');
323
-				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])){
321
+				self::setHeader('Expires', gmdate('D, d M Y H:i:s', $expire) . ' GMT');
322
+				self::setHeader('Last-modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
323
+				if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $lastModified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
324 324
 					$logger->info('The cache page content is not yet expire for the URL [' . $url . '] send 304 header to browser');
325 325
 					self::sendHeaders(304);
326 326
 					return;
327 327
 				}
328
-				else{
328
+				else {
329 329
 					$logger->info('The cache page content is expired or the browser don\'t send the HTTP_IF_MODIFIED_SINCE header for the URL [' . $url . '] send cache headers to tell the browser');
330 330
 					self::sendHeaders(200);
331 331
 					//get the cache content
332 332
 					$content = $cache->get($pageCacheKey);
333
-					if($content){
333
+					if ($content) {
334 334
 						$logger->info('The page content for the URL [' . $url . '] already cached just display it');
335 335
 						//load benchmark class
336 336
 						$benchmark = & class_loader('Benchmark');
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 						
344 344
 						///display the final output
345 345
 						//compress the output if is available
346
-						if (self::$_canCompressOutput){
346
+						if (self::$_canCompressOutput) {
347 347
 							ob_start('ob_gzhandler');
348 348
 						}
349
-						else{
349
+						else {
350 350
 							ob_start();
351 351
 						}
352 352
 						echo $content;
353 353
 						ob_end_flush();
354 354
 						return;
355 355
 					}
356
-					else{
356
+					else {
357 357
 						$logger->info('The page cache content for the URL [' . $url . '] is not valid may be already expired');
358 358
 						$cache->delete($pageCacheKey);
359 359
 					}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 		* Get the final page to be rendered
366 366
 		* @return string
367 367
 		*/
368
-		public function getFinalPageRendered(){
368
+		public function getFinalPageRendered() {
369 369
 			return $this->_pageRender;
370 370
 		}
371 371
 
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 		 * Send the HTTP 404 error if can not found the 
374 374
 		 * routing information for the current request
375 375
 		 */
376
-		public static function send404(){
376
+		public static function send404() {
377 377
 			/********* for logs **************/
378 378
 			//can't use $obj = & get_instance()  here because the global super object will be available until
379 379
 			//the main controller is loaded even for Loader::library('xxxx');
380 380
 			$logger = self::getLogger();
381
-			$request =& class_loader('Request', 'classes');
382
-			$userAgent =& class_loader('Browser');
383
-			$browser = $userAgent->getPlatform().', '.$userAgent->getBrowser().' '.$userAgent->getVersion();
381
+			$request = & class_loader('Request', 'classes');
382
+			$userAgent = & class_loader('Browser');
383
+			$browser = $userAgent->getPlatform() . ', ' . $userAgent->getBrowser() . ' ' . $userAgent->getVersion();
384 384
 			
385 385
 			//here can't use Loader::functions just include the helper manually
386 386
 			require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 			$logger->error($str);
391 391
 			/***********************************/
392 392
 			$path = CORE_VIEWS_PATH . '404.php';
393
-			if(file_exists($path)){
393
+			if (file_exists($path)) {
394 394
 				//compress the output if is available
395
-				if (self::$_canCompressOutput){
395
+				if (self::$_canCompressOutput) {
396 396
 					ob_start('ob_gzhandler');
397 397
 				}
398
-				else{
398
+				else {
399 399
 					ob_start();
400 400
 				}
401 401
 				require_once $path;
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 				self::sendHeaders(404);
404 404
 				echo $output;
405 405
 			}
406
-			else{
407
-				show_error('The 404 view [' .$path. '] does not exist');
406
+			else {
407
+				show_error('The 404 view [' . $path . '] does not exist');
408 408
 			}
409 409
 		}
410 410
 
@@ -412,14 +412,14 @@  discard block
 block discarded – undo
412 412
 		 * Display the error to user
413 413
 		 * @param  array  $data the error information
414 414
 		 */
415
-		public static function sendError(array $data = array()){
415
+		public static function sendError(array $data = array()) {
416 416
 			$path = CORE_VIEWS_PATH . 'errors.php';
417
-			if(file_exists($path)){
417
+			if (file_exists($path)) {
418 418
 				//compress the output if exists
419
-				if (self::$_canCompressOutput){
419
+				if (self::$_canCompressOutput) {
420 420
 					ob_start('ob_gzhandler');
421 421
 				}
422
-				else{
422
+				else {
423 423
 					ob_start();
424 424
 				}
425 425
 				extract($data);
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				self::sendHeaders(503);
429 429
 				echo $output;
430 430
 			}
431
-			else{
431
+			else {
432 432
 				//can't use show_error() at this time because some dependencies not yet loaded and to prevent loop
433 433
 				set_http_status_header(503);
434 434
 				echo 'The error view [' . $path . '] does not exist';
Please login to merge, or discard this patch.
tests/tnhfw/classes/EventInfoTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 		
27 27
 		
28
-		public function testDefaultValue(){
28
+		public function testDefaultValue() {
29 29
 			$e = new EventInfo('foo');
30 30
 			$this->assertSame($e->name, 'foo');
31 31
 			$this->assertSame($e->payload, array());
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			$this->assertFalse($e->stop);
34 34
 		}
35 35
 		
36
-		public function testPayloadValueIsSet(){
36
+		public function testPayloadValueIsSet() {
37 37
 			$e = new EventInfo('foo', array('bar'));
38 38
 			$this->assertSame($e->name, 'foo');
39 39
 			$this->assertSame($e->payload, array('bar'));
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 			$this->assertFalse($e->stop);
42 42
 		}
43 43
 		
44
-		public function testReturnBackValueIsSetToTrue(){
44
+		public function testReturnBackValueIsSetToTrue() {
45 45
 			$e = new EventInfo('foo', array('bar'), true);
46 46
 			$this->assertSame($e->name, 'foo');
47 47
 			$this->assertSame($e->payload, array('bar'));
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 			$this->assertFalse($e->stop);
50 50
 		}
51 51
 		
52
-		public function testStopValueIsSetToTue(){
52
+		public function testStopValueIsSetToTue() {
53 53
 			$e = new EventInfo('foo', array('bar'), true, true);
54 54
 			$this->assertSame($e->name, 'foo');
55 55
 			$this->assertSame($e->payload, array('bar'));
Please login to merge, or discard this patch.
core/classes/Config.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Config{
27
+	class Config {
28 28
 		
29 29
 		/**
30 30
 		 * The list of loaded configuration
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(self::$logger == null){
45
+		private static function getLogger() {
46
+			if (self::$logger == null) {
47 47
 				$logger = array();
48
-				$logger[0] =& class_loader('Log', 'classes');
48
+				$logger[0] = & class_loader('Log', 'classes');
49 49
 				$logger[0]->setLogger('Library::Config');
50 50
 				self::$logger = $logger[0];
51 51
 			}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		 * @param Log $logger the log object
58 58
 		 * @return Log the log instance
59 59
 		 */
60
-		public static function setLogger($logger){
60
+		public static function setLogger($logger) {
61 61
 			self::$logger = $logger;
62 62
 			return self::$logger;
63 63
 		}
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 		/**
66 66
 		 * Initialize the configuration by loading all the configuration from config file
67 67
 		 */
68
-		public static function init(){
68
+		public static function init() {
69 69
 			$logger = static::getLogger();
70 70
 			$logger->debug('Initialization of the configuration');
71 71
 			self::$config = & load_configurations();
72 72
 			self::setBaseUrlUsingServerVar();
73
-			if(ENVIRONMENT == 'production' && in_array(strtolower(self::$config['log_level']), array('debug', 'info','all'))){
73
+			if (ENVIRONMENT == 'production' && in_array(strtolower(self::$config['log_level']), array('debug', 'info', 'all'))) {
74 74
 				$logger->warning('You are in production environment, please set log level to WARNING, ERROR, FATAL to increase the application performance');
75 75
 			}
76 76
 			$logger->info('Configuration initialized successfully');
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		 * @param  mixed $default the default value to use if can not find the config item in the list
84 84
 		 * @return mixed          the config value if exist or the default value
85 85
 		 */
86
-		public static function get($item, $default = null){
86
+		public static function get($item, $default = null) {
87 87
 			$logger = static::getLogger();
88
-			if(array_key_exists($item, self::$config)){
88
+			if (array_key_exists($item, self::$config)) {
89 89
 				return self::$config[$item];
90 90
 			}
91
-			$logger->warning('Cannot find config item ['.$item.'] using the default value ['.$default.']');
91
+			$logger->warning('Cannot find config item [' . $item . '] using the default value [' . $default . ']');
92 92
 			return $default;
93 93
 		}
94 94
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		 * @param string $item  the config item name to set
98 98
 		 * @param mixed $value the config item value
99 99
 		 */
100
-		public static function set($item, $value){
100
+		public static function set($item, $value) {
101 101
 			self::$config[$item] = $value;
102 102
 		}
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * Get all the configuration values
106 106
 		 * @return array the config values
107 107
 		 */
108
-		public static function getAll(){
108
+		public static function getAll() {
109 109
 			return self::$config;
110 110
 		}
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 * Set the configuration values bu merged with the existing configuration
114 114
 		 * @param array $config the config values to add in the configuration list
115 115
 		 */
116
-		public static function setAll(array $config = array()){
116
+		public static function setAll(array $config = array()) {
117 117
 			self::$config = array_merge(self::$config, $config);
118 118
 		}
119 119
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 		 * @param  string $item the config item name to be deleted
123 123
 		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
124 124
 		 */
125
-		public static function delete($item){
125
+		public static function delete($item) {
126 126
 			$logger = static::getLogger();
127
-			if(array_key_exists($item, self::$config)){
128
-				$logger->info('Delete config item ['.$item.']');
127
+			if (array_key_exists($item, self::$config)) {
128
+				$logger->info('Delete config item [' . $item . ']');
129 129
 				unset(self::$config[$item]);
130 130
 				return true;
131 131
 			}
132
-			else{
133
-				$logger->warning('Config item ['.$item.'] to be deleted does not exists');
132
+			else {
133
+				$logger->warning('Config item [' . $item . '] to be deleted does not exists');
134 134
 				return false;
135 135
 			}
136 136
 		}
@@ -139,38 +139,38 @@  discard block
 block discarded – undo
139 139
 		 * Load the configuration file. This an alias to Loader::config()
140 140
 		 * @param  string $config the config name to be loaded
141 141
 		 */
142
-		public static function load($config){
142
+		public static function load($config) {
143 143
 			Loader::config($config);
144 144
 		}
145 145
 
146 146
 		/**
147 147
 		 * Set the configuration for "base_url" if is not set in the configuration
148 148
 		 */
149
-		private static function setBaseUrlUsingServerVar(){
149
+		private static function setBaseUrlUsingServerVar() {
150 150
 			$logger = static::getLogger();
151
-			if (! isset(self::$config['base_url']) || ! is_url(self::$config['base_url'])){
152
-				if(ENVIRONMENT == 'production'){
151
+			if (!isset(self::$config['base_url']) || !is_url(self::$config['base_url'])) {
152
+				if (ENVIRONMENT == 'production') {
153 153
 					$logger->warning('Application base URL is not set or invalid, please set application base URL to increase the application loading time');
154 154
 				}
155 155
 				$baseUrl = null;
156
-				if (isset($_SERVER['SERVER_ADDR'])){
156
+				if (isset($_SERVER['SERVER_ADDR'])) {
157 157
 					//check if the server is running under IPv6
158
-					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE){
159
-						$baseUrl = '['.$_SERVER['SERVER_ADDR'].']';
158
+					if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) {
159
+						$baseUrl = '[' . $_SERVER['SERVER_ADDR'] . ']';
160 160
 					}
161
-					else{
161
+					else {
162 162
 						$baseUrl = $_SERVER['SERVER_ADDR'];
163 163
 					}
164
-					$port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && ! is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https()) ) ? ':' . $_SERVER['SERVER_PORT'] : '');
165
-					$baseUrl = (is_https() ? 'https' : 'http').'://' . $baseUrl . $port
164
+					$port = ((isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT'] != '80' && !is_https() || $_SERVER['SERVER_PORT'] != '443' && is_https())) ? ':' . $_SERVER['SERVER_PORT'] : '');
165
+					$baseUrl = (is_https() ? 'https' : 'http') . '://' . $baseUrl . $port
166 166
 						. substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
167 167
 				}
168
-				else{
168
+				else {
169 169
 					$logger->warning('Can not determine the application base URL automatically, use http://localhost as default');
170 170
 					$baseUrl = 'http://localhost/';
171 171
 				}
172 172
 				self::set('base_url', $baseUrl);
173 173
 			}
174
-			self::$config['base_url'] = rtrim(self::$config['base_url'], '/') .'/';
174
+			self::$config['base_url'] = rtrim(self::$config['base_url'], '/') . '/';
175 175
 		}
176 176
 	}
Please login to merge, or discard this patch.
core/classes/Loader.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26
-	class Loader{
26
+	class Loader {
27 27
 		
28 28
 		/**
29 29
 		 * List of loaded resources
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		private static $logger;
39 39
 
40 40
 
41
-		public function __construct(){
41
+		public function __construct() {
42 42
 			//add the resources already loaded during application bootstrap
43 43
 			//in the list to prevent duplicate or loading the resources again.
44 44
 			static::$loaded = class_loaded();
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 		 * Get the logger singleton instance
52 52
 		 * @return Log the logger instance
53 53
 		 */
54
-		private static function getLogger(){
55
-			if(self::$logger == null){
56
-				self::$logger[0] =& class_loader('Log', 'classes');
54
+		private static function getLogger() {
55
+			if (self::$logger == null) {
56
+				self::$logger[0] = & class_loader('Log', 'classes');
57 57
 				self::$logger[0]->setLogger('Library::Loader');
58 58
 			}
59 59
 			return self::$logger[0];
@@ -67,25 +67,25 @@  discard block
 block discarded – undo
67 67
 		 *
68 68
 		 * @return void
69 69
 		 */
70
-		public static function model($class, $instance = null){
70
+		public static function model($class, $instance = null) {
71 71
 			$logger = static::getLogger();
72 72
 			$class = str_ireplace('.php', '', $class);
73 73
 			$class = trim($class, '/\\');
74
-			$file = ucfirst($class).'.php';
74
+			$file = ucfirst($class) . '.php';
75 75
 			$logger->debug('Loading model [' . $class . '] ...');
76
-			if(! $instance){
76
+			if (!$instance) {
77 77
 				//for module
78
-				if(strpos($class, '/') !== false){
78
+				if (strpos($class, '/') !== false) {
79 79
 					$path = explode('/', $class);
80
-					if(isset($path[1])){
80
+					if (isset($path[1])) {
81 81
 						$instance = strtolower($path[1]);
82 82
 					}
83 83
 				}
84
-				else{
84
+				else {
85 85
 					$instance = strtolower($class);
86 86
 				}
87 87
 			}
88
-			if(isset(static::$loaded[$instance])){
88
+			if (isset(static::$loaded[$instance])) {
89 89
 				$logger->info('Model [' . $class . '] already loaded no need to load it again, cost in performance');
90 90
 				return;
91 91
 			}
@@ -95,43 +95,43 @@  discard block
 block discarded – undo
95 95
 			$searchModuleName = null;
96 96
 			$obj = & get_instance();
97 97
 			//check if the request class contains module name
98
-			if(strpos($class, '/') !== false){
98
+			if (strpos($class, '/') !== false) {
99 99
 				$path = explode('/', $class);
100
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
100
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
101 101
 					$searchModuleName = $path[0];
102 102
 					$class = ucfirst($path[1]);
103 103
 				}
104 104
 			}
105
-			else{
105
+			else {
106 106
 				$class = ucfirst($class);
107 107
 			}
108 108
 
109
-			if(! $searchModuleName && !empty($obj->moduleName)){
109
+			if (!$searchModuleName && !empty($obj->moduleName)) {
110 110
 				$searchModuleName = $obj->moduleName;
111 111
 			}
112 112
 			$moduleModelFilePath = Module::findModelFullPath($class, $searchModuleName);
113
-			if($moduleModelFilePath){
114
-				$logger->info('Found model [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleModelFilePath. '] we will used it');
113
+			if ($moduleModelFilePath) {
114
+				$logger->info('Found model [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleModelFilePath . '] we will used it');
115 115
 				$classFilePath = $moduleModelFilePath;
116 116
 			}
117
-			else{
117
+			else {
118 118
 				$logger->info('Cannot find model [' . $class . '] from modules using the default location');
119 119
 			}
120 120
 			$logger->info('The model file path to be loaded is [' . $classFilePath . ']');
121
-			if(file_exists($classFilePath)){
121
+			if (file_exists($classFilePath)) {
122 122
 				require_once $classFilePath;
123
-				if(class_exists($class)){
123
+				if (class_exists($class)) {
124 124
 					$c = new $class();
125 125
 					$obj = & get_instance();
126 126
 					$obj->{$instance} = $c;
127 127
 					static::$loaded[$instance] = $class;
128 128
 					$logger->info('Model [' . $class . '] --> ' . $classFilePath . ' loaded successfully.');
129 129
 				}
130
-				else{
131
-					show_error('The file '.$classFilePath.' exists but does not contain the class ['. $class . ']');
130
+				else {
131
+					show_error('The file ' . $classFilePath . ' exists but does not contain the class [' . $class . ']');
132 132
 				}
133 133
 			}
134
-			else{
134
+			else {
135 135
 				show_error('Unable to find the model [' . $class . ']');
136 136
 			}
137 137
 		}
@@ -146,31 +146,31 @@  discard block
 block discarded – undo
146 146
 		 *
147 147
 		 * @return void
148 148
 		 */
149
-		public static function library($class, $instance = null, array $params = array()){
149
+		public static function library($class, $instance = null, array $params = array()) {
150 150
 			$logger = static::getLogger();
151 151
 			$class = str_ireplace('.php', '', $class);
152 152
 			$class = trim($class, '/\\');
153
-			$file = ucfirst($class) .'.php';
153
+			$file = ucfirst($class) . '.php';
154 154
 			$logger->debug('Loading library [' . $class . '] ...');
155
-			if(! $instance){
155
+			if (!$instance) {
156 156
 				//for module
157
-				if(strpos($class, '/') !== false){
157
+				if (strpos($class, '/') !== false) {
158 158
 					$path = explode('/', $class);
159
-					if(isset($path[1])){
159
+					if (isset($path[1])) {
160 160
 						$instance = strtolower($path[1]);
161 161
 					}
162 162
 				}
163
-				else{
163
+				else {
164 164
 					$instance = strtolower($class);
165 165
 				}
166 166
 			}
167
-			if(isset(static::$loaded[$instance])){
167
+			if (isset(static::$loaded[$instance])) {
168 168
 				$logger->info('Library [' . $class . '] already loaded no need to load it again, cost in performance');
169 169
 				return;
170 170
 			}
171 171
 			$obj = & get_instance();
172 172
 			//TODO for Database library
173
-			if(strtolower($class) == 'database'){
173
+			if (strtolower($class) == 'database') {
174 174
 				$logger->info('This is the Database library ...');
175 175
 				$dbInstance = & class_loader('Database', 'classes', $params);
176 176
 				$obj->{$instance} = $dbInstance;
@@ -180,44 +180,44 @@  discard block
 block discarded – undo
180 180
 			}
181 181
 			$libraryFilePath = null;
182 182
 			$logger->debug('Check if this is a system library ...');
183
-			if(file_exists(CORE_LIBRARY_PATH . $file)){
183
+			if (file_exists(CORE_LIBRARY_PATH . $file)) {
184 184
 				$libraryFilePath = CORE_LIBRARY_PATH . $file;
185 185
 				$class = ucfirst($class);
186 186
 				$logger->info('This library is a system library');
187 187
 			}
188
-			else{
188
+			else {
189 189
 				$logger->info('This library is not a system library');	
190 190
 				//first check if this library is in the module
191 191
 				$logger->debug('Checking library [' . $class . '] from module list ...');
192 192
 				$searchModuleName = null;
193 193
 				//check if the request class contains module name
194
-				if(strpos($class, '/') !== false){
194
+				if (strpos($class, '/') !== false) {
195 195
 					$path = explode('/', $class);
196
-					if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
196
+					if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
197 197
 						$searchModuleName = $path[0];
198 198
 						$class = ucfirst($path[1]);
199 199
 					}
200 200
 				}
201
-				else{
201
+				else {
202 202
 					$class = ucfirst($class);
203 203
 				}
204
-				if(! $searchModuleName && !empty($obj->moduleName)){
204
+				if (!$searchModuleName && !empty($obj->moduleName)) {
205 205
 					$searchModuleName = $obj->moduleName;
206 206
 				}
207 207
 				$moduleLibraryPath = Module::findLibraryFullPath($class, $searchModuleName);
208
-				if($moduleLibraryPath){
209
-					$logger->info('Found library [' . $class . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLibraryPath. '] we will used it');
208
+				if ($moduleLibraryPath) {
209
+					$logger->info('Found library [' . $class . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLibraryPath . '] we will used it');
210 210
 					$libraryFilePath = $moduleLibraryPath;
211 211
 				}
212
-				else{
212
+				else {
213 213
 					$logger->info('Cannot find library [' . $class . '] from modules using the default location');
214 214
 				}
215 215
 			}
216
-			if(! $libraryFilePath){
216
+			if (!$libraryFilePath) {
217 217
 				$searchDir = array(LIBRARY_PATH);
218
-				foreach($searchDir as $dir){
218
+				foreach ($searchDir as $dir) {
219 219
 					$filePath = $dir . $file;
220
-					if(file_exists($filePath)){
220
+					if (file_exists($filePath)) {
221 221
 						$libraryFilePath = $filePath;
222 222
 						//is already found not to continue
223 223
 						break;
@@ -225,20 +225,20 @@  discard block
 block discarded – undo
225 225
 				}
226 226
 			}
227 227
 			$logger->info('The library file path to be loaded is [' . $libraryFilePath . ']');
228
-			if($libraryFilePath){
228
+			if ($libraryFilePath) {
229 229
 				require_once $libraryFilePath;
230
-				if(class_exists($class)){
230
+				if (class_exists($class)) {
231 231
 					$c = $params ? new $class($params) : new $class();
232 232
 					$obj = & get_instance();
233 233
 					$obj->{$instance} = $c;
234 234
 					static::$loaded[$instance] = $class;
235 235
 					$logger->info('Library [' . $class . '] --> ' . $libraryFilePath . ' loaded successfully.');
236 236
 				}
237
-				else{
238
-					show_error('The file '.$libraryFilePath.' exists but does not contain the class '.$class);
237
+				else {
238
+					show_error('The file ' . $libraryFilePath . ' exists but does not contain the class ' . $class);
239 239
 				}
240 240
 			}
241
-			else{
241
+			else {
242 242
 				show_error('Unable to find library class [' . $class . ']');
243 243
 			}
244 244
 		}
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 		 *
251 251
 		 * @return void
252 252
 		 */
253
-		public static function functions($function){
253
+		public static function functions($function) {
254 254
 			$logger = static::getLogger();
255 255
 			$function = str_ireplace('.php', '', $function);
256 256
 			$function = trim($function, '/\\');
257 257
 			$function = str_ireplace('function_', '', $function);
258
-			$file = 'function_'.$function.'.php';
258
+			$file = 'function_' . $function . '.php';
259 259
 			$logger->debug('Loading helper [' . $function . '] ...');
260
-			if(isset(static::$loaded['function_' . $function])){
260
+			if (isset(static::$loaded['function_' . $function])) {
261 261
 				$logger->info('Helper [' . $function . '] already loaded no need to load it again, cost in performance');
262 262
 				return;
263 263
 			}
@@ -267,30 +267,30 @@  discard block
 block discarded – undo
267 267
 			$searchModuleName = null;
268 268
 			$obj = & get_instance();
269 269
 			//check if the request class contains module name
270
-			if(strpos($function, '/') !== false){
270
+			if (strpos($function, '/') !== false) {
271 271
 				$path = explode('/', $function);
272
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
272
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
273 273
 					$searchModuleName = $path[0];
274 274
 					$function = 'function_' . $path[1] . '.php';
275
-					$file = $path[0] . DS . 'function_'.$function.'.php';
275
+					$file = $path[0] . DS . 'function_' . $function . '.php';
276 276
 				}
277 277
 			}
278
-			if(! $searchModuleName && !empty($obj->moduleName)){
278
+			if (!$searchModuleName && !empty($obj->moduleName)) {
279 279
 				$searchModuleName = $obj->moduleName;
280 280
 			}
281 281
 			$moduleFunctionPath = Module::findFunctionFullPath($function, $searchModuleName);
282
-			if($moduleFunctionPath){
283
-				$logger->info('Found helper [' . $function . '] from module [' .$searchModuleName. '], the file path is [' .$moduleFunctionPath. '] we will used it');
282
+			if ($moduleFunctionPath) {
283
+				$logger->info('Found helper [' . $function . '] from module [' . $searchModuleName . '], the file path is [' . $moduleFunctionPath . '] we will used it');
284 284
 				$functionFilePath = $moduleFunctionPath;
285 285
 			}
286
-			else{
286
+			else {
287 287
 				$logger->info('Cannot find helper [' . $function . '] from modules using the default location');
288 288
 			}
289
-			if(! $functionFilePath){
289
+			if (!$functionFilePath) {
290 290
 				$searchDir = array(FUNCTIONS_PATH, CORE_FUNCTIONS_PATH);
291
-				foreach($searchDir as $dir){
291
+				foreach ($searchDir as $dir) {
292 292
 					$filePath = $dir . $file;
293
-					if(file_exists($filePath)){
293
+					if (file_exists($filePath)) {
294 294
 						$functionFilePath = $filePath;
295 295
 						//is already found not to continue
296 296
 						break;
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
 				}
299 299
 			}
300 300
 			$logger->info('The helper file path to be loaded is [' . $functionFilePath . ']');
301
-			if($functionFilePath){
301
+			if ($functionFilePath) {
302 302
 				require_once $functionFilePath;
303 303
 				static::$loaded['function_' . $function] = $functionFilePath;
304 304
 				$logger->info('Helper [' . $function . '] --> ' . $functionFilePath . ' loaded successfully.');
305 305
 			}
306
-			else{
306
+			else {
307 307
 				show_error('Unable to find helper file [' . $file . ']');
308 308
 			}
309 309
 		}
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
 		 *
316 316
 		 * @return void
317 317
 		 */
318
-		public static function config($filename){
318
+		public static function config($filename) {
319 319
 			$logger = static::getLogger();
320 320
 			$filename = str_ireplace('.php', '', $filename);
321 321
 			$filename = trim($filename, '/\\');
322 322
 			$filename = str_ireplace('config_', '', $filename);
323
-			$file = 'config_'.$filename.'.php';
323
+			$file = 'config_' . $filename . '.php';
324 324
 			$logger->debug('Loading configuration [' . $filename . '] ...');
325
-			if(isset(static::$loaded['config_' . $filename])){
325
+			if (isset(static::$loaded['config_' . $filename])) {
326 326
 				$logger->info('Configuration [' . $file . '] already loaded no need to load it again, cost in performance');
327 327
 				return;
328 328
 			}
@@ -332,33 +332,33 @@  discard block
 block discarded – undo
332 332
 			$searchModuleName = null;
333 333
 			$obj = & get_instance();
334 334
 			//check if the request class contains module name
335
-			if(strpos($filename, '/') !== false){
335
+			if (strpos($filename, '/') !== false) {
336 336
 				$path = explode('/', $filename);
337
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
337
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
338 338
 					$searchModuleName = $path[0];
339 339
 					$filename = $path[1] . '.php';
340 340
 				}
341 341
 			}
342
-			if(! $searchModuleName && !empty($obj->moduleName)){
342
+			if (!$searchModuleName && !empty($obj->moduleName)) {
343 343
 				$searchModuleName = $obj->moduleName;
344 344
 			}
345 345
 			$moduleConfigPath = Module::findConfigFullPath($filename, $searchModuleName);
346
-			if($moduleConfigPath){
347
-				$logger->info('Found config [' . $filename . '] from module [' .$searchModuleName. '], the file path is [' .$moduleConfigPath. '] we will used it');
346
+			if ($moduleConfigPath) {
347
+				$logger->info('Found config [' . $filename . '] from module [' . $searchModuleName . '], the file path is [' . $moduleConfigPath . '] we will used it');
348 348
 				$configFilePath = $moduleConfigPath;
349 349
 			}
350
-			else{
350
+			else {
351 351
 				$logger->info('Cannot find config [' . $filename . '] from modules using the default location');
352 352
 			}
353 353
 			$logger->info('The config file path to be loaded is [' . $configFilePath . ']');
354
-			if(file_exists($configFilePath)){
354
+			if (file_exists($configFilePath)) {
355 355
 				require_once $configFilePath;
356
-				if(! empty($config) && is_array($config)){
356
+				if (!empty($config) && is_array($config)) {
357 357
 					Config::setAll($config);
358 358
 				}
359 359
 			}
360
-			else{
361
-				show_error('Unable to find config file ['. $configFilePath . ']');
360
+			else {
361
+				show_error('Unable to find config file [' . $configFilePath . ']');
362 362
 			}
363 363
 			static::$loaded['config_' . $filename] = $configFilePath;
364 364
 			$logger->info('Configuration [' . $configFilePath . '] loaded successfully.');
@@ -374,14 +374,14 @@  discard block
 block discarded – undo
374 374
 		 *
375 375
 		 * @return void
376 376
 		 */
377
-		public static function lang($language){
377
+		public static function lang($language) {
378 378
 			$logger = static::getLogger();
379 379
 			$language = str_ireplace('.php', '', $language);
380 380
 			$language = trim($language, '/\\');
381 381
 			$language = str_ireplace('lang_', '', $language);
382
-			$file = 'lang_'.$language.'.php';
382
+			$file = 'lang_' . $language . '.php';
383 383
 			$logger->debug('Loading language [' . $language . '] ...');
384
-			if(isset(static::$loaded['lang_' . $language])){
384
+			if (isset(static::$loaded['lang_' . $language])) {
385 385
 				$logger->info('Language [' . $language . '] already loaded no need to load it again, cost in performance');
386 386
 				return;
387 387
 			}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			$cfgKey = get_config('language_cookie_name');
392 392
 			$objCookie = & class_loader('Cookie');
393 393
 			$cookieLang = $objCookie->get($cfgKey);
394
-			if($cookieLang){
394
+			if ($cookieLang) {
395 395
 				$appLang = $cookieLang;
396 396
 			}
397 397
 			$languageFilePath = null;
@@ -400,30 +400,30 @@  discard block
 block discarded – undo
400 400
 			$searchModuleName = null;
401 401
 			$obj = & get_instance();
402 402
 			//check if the request class contains module name
403
-			if(strpos($language, '/') !== false){
403
+			if (strpos($language, '/') !== false) {
404 404
 				$path = explode('/', $language);
405
-				if(isset($path[0]) && in_array($path[0], Module::getModuleList())){
405
+				if (isset($path[0]) && in_array($path[0], Module::getModuleList())) {
406 406
 					$searchModuleName = $path[0];
407 407
 					$language = 'lang_' . $path[1] . '.php';
408
-					$file = $path[0] . DS .$language;
408
+					$file = $path[0] . DS . $language;
409 409
 				}
410 410
 			}
411
-			if(! $searchModuleName && !empty($obj->moduleName)){
411
+			if (!$searchModuleName && !empty($obj->moduleName)) {
412 412
 				$searchModuleName = $obj->moduleName;
413 413
 			}
414 414
 			$moduleLanguagePath = Module::findLanguageFullPath($language, $searchModuleName, $appLang);
415
-			if($moduleLanguagePath){
416
-				$logger->info('Found language [' . $language . '] from module [' .$searchModuleName. '], the file path is [' .$moduleLanguagePath. '] we will used it');
415
+			if ($moduleLanguagePath) {
416
+				$logger->info('Found language [' . $language . '] from module [' . $searchModuleName . '], the file path is [' . $moduleLanguagePath . '] we will used it');
417 417
 				$languageFilePath = $moduleLanguagePath;
418 418
 			}
419
-			else{
419
+			else {
420 420
 				$logger->info('Cannot find language [' . $language . '] from modules using the default location');
421 421
 			}
422
-			if(! $languageFilePath){
422
+			if (!$languageFilePath) {
423 423
 				$searchDir = array(APP_LANG_PATH, CORE_LANG_PATH);
424
-				foreach($searchDir as $dir){
424
+				foreach ($searchDir as $dir) {
425 425
 					$filePath = $dir . $appLang . DS . $file;
426
-					if(file_exists($filePath)){
426
+					if (file_exists($filePath)) {
427 427
 						$languageFilePath = $filePath;
428 428
 						//is already found not to continue
429 429
 						break;
@@ -431,12 +431,12 @@  discard block
 block discarded – undo
431 431
 				}
432 432
 			}
433 433
 			$logger->info('The language file path to be loaded is [' . $languageFilePath . ']');
434
-			if($languageFilePath){
434
+			if ($languageFilePath) {
435 435
 				require_once $languageFilePath;
436
-				if(! empty($lang) && is_array($lang)){
437
-					$logger->info('Language file  [' .$languageFilePath. '] contains the valid languages keys add them to language list');
436
+				if (!empty($lang) && is_array($lang)) {
437
+					$logger->info('Language file  [' . $languageFilePath . '] contains the valid languages keys add them to language list');
438 438
 					//Note: may be here the class 'Lang' not yet loaded
439
-					$langObj =& class_loader('Lang', 'classes');
439
+					$langObj = & class_loader('Lang', 'classes');
440 440
 					$langObj->addLangMessages($lang);
441 441
 					//free the memory
442 442
 					unset($lang);
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 				static::$loaded['lang_' . $language] = $languageFilePath;
445 445
 				$logger->info('Language [' . $language . '] --> ' . $languageFilePath . ' loaded successfully.');
446 446
 			}
447
-			else{
447
+			else {
448 448
 				show_error('Unable to find language file [' . $file . ']');
449 449
 			}
450 450
 		}
451 451
 
452 452
 
453
-		private function getResourcesFromAutoloadConfig(){
453
+		private function getResourcesFromAutoloadConfig() {
454 454
 			$autoloads = array();
455 455
 			$autoloads['config']    = array();
456 456
 			$autoloads['languages'] = array();
@@ -458,22 +458,22 @@  discard block
 block discarded – undo
458 458
 			$autoloads['models']    = array();
459 459
 			$autoloads['functions'] = array();
460 460
 			//loading of the resources in autoload.php configuration file
461
-			if(file_exists(CONFIG_PATH . 'autoload.php')){
461
+			if (file_exists(CONFIG_PATH . 'autoload.php')) {
462 462
 				require_once CONFIG_PATH . 'autoload.php';
463
-				if(! empty($autoload) && is_array($autoload)){
463
+				if (!empty($autoload) && is_array($autoload)) {
464 464
 					$autoloads = array_merge($autoloads, $autoload);
465 465
 					unset($autoload);
466 466
 				}
467 467
 			}
468 468
 			//loading autoload configuration for modules
469 469
 			$modulesAutoloads = Module::getModulesAutoloadConfig();
470
-			if(! empty($modulesAutoloads) && is_array($modulesAutoloads)){
470
+			if (!empty($modulesAutoloads) && is_array($modulesAutoloads)) {
471 471
 				$autoloads = array_merge_recursive($autoloads, $modulesAutoloads);
472 472
 			}
473 473
 			return $autoloads;
474 474
 		}
475 475
 
476
-		private function loadResourcesFromAutoloadConfig(){
476
+		private function loadResourcesFromAutoloadConfig() {
477 477
 			$autoloads = array();
478 478
 			$autoloads['config']    = array();
479 479
 			$autoloads['languages'] = array();
@@ -485,29 +485,29 @@  discard block
 block discarded – undo
485 485
 
486 486
 			$autoloads = array_merge($autoloads, $list);
487 487
 			//config autoload
488
-			foreach($autoloads['config'] as $c){
488
+			foreach ($autoloads['config'] as $c) {
489 489
 				$this->config($c);
490 490
 			}
491 491
 			
492 492
 			//languages autoload
493
-			foreach($autoloads['languages'] as $language){
493
+			foreach ($autoloads['languages'] as $language) {
494 494
 				$this->lang($language);
495 495
 			}
496 496
 			
497 497
 			//libraries autoload
498
-			foreach($autoloads['libraries'] as $library){
498
+			foreach ($autoloads['libraries'] as $library) {
499 499
 				$this->library($library);
500 500
 			}
501 501
 
502 502
 			//models autoload
503
-			if(! empty($autoloads['models']) && is_array($autoloads['models'])){
503
+			if (!empty($autoloads['models']) && is_array($autoloads['models'])) {
504 504
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
505
-				foreach($autoloads['models'] as $model){
505
+				foreach ($autoloads['models'] as $model) {
506 506
 					$this->model($model);
507 507
 				}
508 508
 			}
509 509
 			
510
-			foreach($autoloads['functions'] as $function){
510
+			foreach ($autoloads['functions'] as $function) {
511 511
 				$this->functions($function);
512 512
 			}
513 513
 		}
Please login to merge, or discard this patch.
core/libraries/FormValidation.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
     */
26 26
 
27 27
 
28
-     class FormValidation{
28
+     class FormValidation {
29 29
 		 
30 30
         /**
31 31
          * The form validation status
32 32
          * @var boolean
33 33
          */
34
-        protected $_success  = false;
34
+        protected $_success = false;
35 35
 
36 36
         /**
37 37
          * The list of errors messages
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
         protected $_errorsMessages = array();
41 41
         
42 42
         // Array of rule sets, fieldName => PIPE seperated ruleString
43
-        protected $_rules             = array();
43
+        protected $_rules = array();
44 44
         
45 45
         // Array of errors, niceName => Error Message
46
-        protected $_errors             = array();
46
+        protected $_errors = array();
47 47
         
48 48
         // Array of post Key => Nice name labels
49
-        protected $_labels          = array();
49
+        protected $_labels = array();
50 50
         
51 51
         /**
52 52
          * The errors delimiters
53 53
          * @var array
54 54
          */
55
-        protected $_allErrorsDelimiter   = array('<div class="error">', '</div>');
55
+        protected $_allErrorsDelimiter = array('<div class="error">', '</div>');
56 56
 
57 57
         /**
58 58
          * The each error delimiter
59 59
          * @var array
60 60
          */
61
-        protected $_eachErrorDelimiter   = array('<p class="error">', '</p>');
61
+        protected $_eachErrorDelimiter = array('<p class="error">', '</p>');
62 62
         
63 63
 		/**
64 64
          * Indicated if need force the validation to be failed
65 65
          * @var boolean
66 66
          */
67
-        protected $_forceFail            = false;
67
+        protected $_forceFail = false;
68 68
 
69 69
         /**
70 70
          * The list of the error messages overrides by the original
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
          * @return void
99 99
          */
100 100
         public function __construct() {
101
-            $this->logger =& class_loader('Log', 'classes');
101
+            $this->logger = & class_loader('Log', 'classes');
102 102
             $this->logger->setLogger('Library::FormValidation');
103 103
            
104 104
 		   //Load form validation language message
105 105
             Loader::lang('form_validation');
106 106
             $obj = & get_instance();
107
-            $this->_errorsMessages  = array(
107
+            $this->_errorsMessages = array(
108 108
                         'required'         => $obj->lang->get('fv_required'),
109 109
                         'min_length'       => $obj->lang->get('fv_min_length'),
110 110
                         'max_length'       => $obj->lang->get('fv_max_length'),
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             $this->_success              = false;
142 142
             $this->_forceFail            = false;
143 143
             $this->data                  = array();
144
-			$this->enableCsrfCheck       = false;
144
+			$this->enableCsrfCheck = false;
145 145
         }
146 146
 
147 147
         /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		 *
151 151
          * @return FormValidation Current instance of object.
152 152
          */
153
-        public function setData(array $data){
153
+        public function setData(array $data) {
154 154
             $this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data));
155 155
             $this->data = $data;
156 156
 			return $this;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
          * Get the form validation data
161 161
          * @return array the form validation data to be validated
162 162
          */
163
-        public function getData(){
163
+        public function getData() {
164 164
             return $this->data;
165 165
         }
166 166
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		*
170 170
 		* @return string the function name
171 171
 		*/
172
-        protected function _toCallCase($funcName, $prefix='_validate') {
172
+        protected function _toCallCase($funcName, $prefix = '_validate') {
173 173
             $funcName = strtolower($funcName);
174 174
             $finalFuncName = $prefix;
175 175
             foreach (explode('_', $funcName) as $funcNamePart) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
          * @return boolean Whether or not the form has been submitted or the data is available for validation.
194 194
          */
195 195
         public function canDoValidation() {
196
-            return get_instance()->request->method() === 'POST' || ! empty($this->data);
196
+            return get_instance()->request->method() === 'POST' || !empty($this->data);
197 197
         }
198 198
 
199 199
         /**
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
          * afterwards.
216 216
          */
217 217
         protected function _run() {
218
-            if(get_instance()->request->method() == 'POST' || $this->enableCsrfCheck){
218
+            if (get_instance()->request->method() == 'POST' || $this->enableCsrfCheck) {
219 219
                 $this->logger->debug('Check if CSRF is enabled in configuration');
220 220
                 //first check for CSRF
221
-                if ((get_config('csrf_enable', false) || $this->enableCsrfCheck) && ! Security::validateCSRF()){
221
+                if ((get_config('csrf_enable', false) || $this->enableCsrfCheck) && !Security::validateCSRF()) {
222 222
                     show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
223 223
                 }
224
-                else{
224
+                else {
225 225
                     $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
226 226
                 }
227 227
             }
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
             $this->_forceFail = false;
230 230
 
231 231
             foreach ($this->getData() as $inputName => $inputVal) {
232
-    			if(is_array($this->data[$inputName])){
232
+    			if (is_array($this->data[$inputName])) {
233 233
     				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
234 234
     			}
235
-    			else{
235
+    			else {
236 236
     				$this->data[$inputName] = trim($this->data[$inputName]);
237 237
     			}
238 238
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         public function setRule($inputField, $inputLabel, $ruleSets) {
260 260
             $this->_rules[$inputField] = $ruleSets;
261 261
             $this->_labels[$inputField] = $inputLabel;
262
-            $this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']');
262
+            $this->logger->info('Set the field rule: name [' . $inputField . '], label [' . $inputLabel . '], rules [' . $ruleSets . ']');
263 263
             return $this;
264 264
         }
265 265
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
             }
424 424
             $errorOutput .= $errorsEnd;
425 425
             echo ($echo) ? $errorOutput : '';
426
-            return (! $echo) ? $errorOutput : null;
426
+            return (!$echo) ? $errorOutput : null;
427 427
         }
428 428
 
429 429
         /**
@@ -448,25 +448,25 @@  discard block
 block discarded – undo
448 448
             /*
449 449
             //////////////// hack for regex rule that can contain "|"
450 450
             */
451
-            if(strpos($ruleString, 'regex') !== false){
451
+            if (strpos($ruleString, 'regex') !== false) {
452 452
                 $regexRule = array();
453 453
                 $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
454 454
                 preg_match($rule, $ruleString, $regexRule);
455 455
                 $ruleStringTemp = preg_replace($rule, '', $ruleString);
456
-                 if(!empty($regexRule[0])){
456
+                 if (!empty($regexRule[0])) {
457 457
                      $ruleSets[] = $regexRule[0];
458 458
                  }
459 459
                  $ruleStringRegex = explode('|', $ruleStringTemp);
460 460
                 foreach ($ruleStringRegex as $rule) {
461 461
                     $rule = trim($rule);
462
-                    if($rule){
462
+                    if ($rule) {
463 463
                         $ruleSets[] = $rule;
464 464
                     }
465 465
                 }
466 466
                  
467 467
             }
468 468
             /***********************************/
469
-            else{
469
+            else {
470 470
                 if (strpos($ruleString, '|') !== FALSE) {
471 471
                     $ruleSets = explode('|', $ruleString);
472 472
                 } else {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
          * @return void
499 499
          */
500 500
         protected function _validateRule($inputName, $inputVal, $ruleName) {
501
-            $this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']');
501
+            $this->logger->debug('Rule validation of field [' . $inputName . '], value [' . $inputVal . '], rule [' . $ruleName . ']');
502 502
             // Array to store args
503 503
             $ruleArgs = array();
504 504
 
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
                 $key = $i - 1;
544 544
                 $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
545 545
             }
546
-            if (! array_key_exists($inputName, $this->_errors)) {
546
+            if (!array_key_exists($inputName, $this->_errors)) {
547 547
                 $this->_errors[$inputName] = $rulePhrase;
548 548
             }
549 549
         }
@@ -595,13 +595,13 @@  discard block
 block discarded – undo
595 595
          */
596 596
 		protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
597 597
             $inputVal = $this->post($inputName);
598
-            if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
598
+            if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
599 599
                 $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
600 600
                 if ($inputVal == '' && $callbackReturn == true) {
601 601
                     $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
602 602
                 }
603 603
             } 
604
-			else if($inputVal == '') {
604
+			else if ($inputVal == '') {
605 605
 				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
606 606
             }
607 607
         }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
         protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
628 628
             if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
629 629
 				$result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
630
-				if(! $result){
630
+				if (!$result) {
631 631
 					$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
632 632
 				}
633 633
             }
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
                         continue;
662 662
                     }
663 663
                 } 
664
-				else{
664
+				else {
665 665
                     if ($inputVal == $doNotEqual) {
666 666
                         $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
667 667
                         continue;
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
          */
692 692
         protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) {
693 693
             $inputVal = $this->post($inputName);
694
-            if (! preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) {
695
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
694
+            if (!preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) {
695
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
696 696
                     return;
697 697
                 }
698 698
                 $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
         protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) {
709 709
             $inputVal = $this->post($inputName);
710 710
             if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
711
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
711
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
712 712
                     return;
713 713
                 }
714 714
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
         protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) {
725 725
             $inputVal = $this->post($inputName);
726 726
             if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
727
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
727
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
728 728
                     return;
729 729
                 }
730 730
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
         protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) {
741 741
             $inputVal = $this->post($inputName);
742 742
             if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
743
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
743
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
744 744
                     return;
745 745
                 }
746 746
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
     	protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
757 757
             $inputVal = $this->post($inputName);
758 758
             if ($inputVal >= $ruleArgs[1]) { 
759
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
759
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
760 760
                     return;
761 761
                 }
762 762
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
     	protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
773 773
             $inputVal = $this->post($inputName);
774 774
             if ($inputVal <= $ruleArgs[1]) {
775
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
775
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
776 776
                     return;
777 777
                 }
778 778
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -787,8 +787,8 @@  discard block
 block discarded – undo
787 787
          */
788 788
     	protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
789 789
             $inputVal = $this->post($inputName);
790
-            if (! is_numeric($inputVal)) {
791
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
790
+            if (!is_numeric($inputVal)) {
791
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
792 792
                     return;
793 793
                 }
794 794
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
805 805
             $inputVal = $this->post($inputName);
806 806
     		$obj = & get_instance();
807
-    		if(! isset($obj->database)){
807
+    		if (!isset($obj->database)) {
808 808
     			return;
809 809
     		}
810 810
     		list($table, $column) = explode('.', $ruleArgs[1]);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
     			          ->get();
814 814
     		$nb = $obj->database->numRows();
815 815
             if ($nb == 0) {
816
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
816
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
817 817
                     return;
818 818
                 }
819 819
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
     	protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
830 830
             $inputVal = $this->post($inputName);
831 831
     		$obj = & get_instance();
832
-    		if(! isset($obj->database)){
832
+    		if (!isset($obj->database)) {
833 833
     			return;
834 834
     		}
835 835
     		list($table, $column) = explode('.', $ruleArgs[1]);
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
     			          ->get();
839 839
     		$nb = $obj->database->numRows();
840 840
             if ($nb != 0) {
841
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
841
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
842 842
                     return;
843 843
                 }
844 844
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -854,11 +854,11 @@  discard block
 block discarded – undo
854 854
     	protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
855 855
             $inputVal = $this->post($inputName);
856 856
     		$obj = & get_instance();
857
-    		if(! isset($obj->database)){
857
+    		if (!isset($obj->database)) {
858 858
     			return;
859 859
     		}
860 860
     		$data = explode(',', $ruleArgs[1]);
861
-    		if(count($data) < 2){
861
+    		if (count($data) < 2) {
862 862
     			return;
863 863
     		}
864 864
     		list($table, $column) = explode('.', $data[0]);
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                 		  ->get();
870 870
     		$nb = $obj->database->numRows();
871 871
             if ($nb != 0) {
872
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
872
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
873 873
                     return;
874 874
                 }
875 875
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -886,8 +886,8 @@  discard block
 block discarded – undo
886 886
             $inputVal = $this->post($inputName);
887 887
     		$list = explode(',', $ruleArgs[1]);
888 888
             $list = array_map('trim', $list);
889
-            if (! in_array($inputVal, $list)) {
890
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
889
+            if (!in_array($inputVal, $list)) {
890
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
891 891
                     return;
892 892
                 }
893 893
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -903,8 +903,8 @@  discard block
 block discarded – undo
903 903
         protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
904 904
             $inputVal = $this->post($inputName);
905 905
     		$regex = $ruleArgs[1];
906
-            if (! preg_match($regex, $inputVal)) {
907
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
906
+            if (!preg_match($regex, $inputVal)) {
907
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
908 908
                     return;
909 909
                 }
910 910
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
Please login to merge, or discard this patch.
tests/include/common.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 		//put the first letter of class to upper case 
30 30
 		$class = ucfirst($class);
31 31
 		static $classes = array();
32
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
32
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
33 33
 			return $classes[$class];
34 34
 		}
35 35
 		$found = false;
36 36
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
37 37
 			$file = $path . $dir . '/' . $class . '.php';
38
-			if(file_exists($file)){
39
-				if(class_exists($class, false) === false){
38
+			if (file_exists($file)) {
39
+				if (class_exists($class, false) === false) {
40 40
 					require_once $file;
41 41
 				}
42 42
 				//already found
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 				break;
45 45
 			}
46 46
 		}
47
-		if(! $found){
47
+		if (!$found) {
48 48
 			//can't use show_error() at this time because some dependencies not yet loaded
49 49
 			set_http_status_header(503);
50 50
 			echo 'Cannot find the class [' . $class . ']';
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		/*
55 55
 		   TODO use the best method to get the Log instance
56 56
 		 */
57
-		if($class == 'Log'){
57
+		if ($class == 'Log') {
58 58
 			//can't use the instruction like "return new Log()" 
59 59
 			//because we need return the reference instance of the loaded class.
60 60
 			$log = new Log();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	function & class_loaded($class = null){
74 74
 		static $list = array();
75
-		if($class != null){
75
+		if ($class != null) {
76 76
 			$list[strtolower($class)] = $class;
77 77
 		}
78 78
 		return $list;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 	function & load_configurations(array $overwrite_values = array()){
82 82
 		static $config;
83
-		if(empty($config)){
83
+		if (empty($config)) {
84 84
 			$file = CONFIG_PATH . 'config.php';
85 85
 			require_once $file;
86 86
 		
@@ -94,53 +94,53 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	*  @test
96 96
 	*/
97
-	function get_config($key, $default = null){
97
+	function get_config($key, $default = null) {
98 98
 		static $cfg;
99
-		if(empty($cfg)){
99
+		if (empty($cfg)) {
100 100
 			$cfg[0] = & load_configurations();
101 101
 		}
102 102
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
103 103
 	}
104 104
 
105
-	function save_to_log($level, $message, $logger = null){
106
-		echo 'save_to_log('.$level . ',' . $message . ',' . $logger . ")\n";
105
+	function save_to_log($level, $message, $logger = null) {
106
+		echo 'save_to_log(' . $level . ',' . $message . ',' . $logger . ")\n";
107 107
 	}
108 108
 
109 109
 	
110
-	function set_http_status_header($code = 200, $text = null){
110
+	function set_http_status_header($code = 200, $text = null) {
111 111
 		echo 'header(' . $code . ', ' . $text . ')';
112 112
 		return true;
113 113
 	}
114 114
 
115 115
 	
116
-	function show_error($msg, $title = 'error', $logging = true){
116
+	function show_error($msg, $title = 'error', $logging = true) {
117 117
 		//show only and continue to help track of some error occured
118 118
 		echo 'show_error(' . $msg . ', ' . $title . ', ' . ($logging ? 'Y' : 'N') . ")\n";
119 119
 	}
120 120
 
121
-	function is_https(){
121
+	function is_https() {
122 122
 		return false;
123 123
 	}
124 124
 	
125 125
 	/**
126 126
 	*  @test
127 127
 	*/
128
-	function is_url($url){
128
+	function is_url($url) {
129 129
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
130 130
 	}
131 131
 		
132
-	function php_exception_handler($ex){
132
+	function php_exception_handler($ex) {
133 133
 		//show only and continue to help track of some error occured
134
-		echo 'php_exception_handler('.$ex->getMessage().', '.$ex->getFile().', '.$ex->getLine() . ")\n";
134
+		echo 'php_exception_handler(' . $ex->getMessage() . ', ' . $ex->getFile() . ', ' . $ex->getLine() . ")\n";
135 135
 	}
136 136
 	
137 137
 	
138
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
138
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
139 139
 		//show only and continue to help track of some error occured
140
-		echo 'php_error_handler('.$errno .', ' . $errstr.', ' . $errfile.', '.$errline . ")\n";
140
+		echo 'php_error_handler(' . $errno . ', ' . $errstr . ', ' . $errfile . ', ' . $errline . ")\n";
141 141
 	}
142 142
 
143
-	function php_shudown_handler(){
143
+	function php_shudown_handler() {
144 144
 		return true;
145 145
 	}
146 146
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	/**
149 149
 	*  @test
150 150
 	*/
151
-	function attributes_to_string(array $attributes){
151
+	function attributes_to_string(array $attributes) {
152 152
 		$str = ' ';
153 153
 		//we check that the array passed as an argument is not empty.
154
-		if(! empty($attributes)){
155
-			foreach($attributes as $key => $value){
154
+		if (!empty($attributes)) {
155
+			foreach ($attributes as $key => $value) {
156 156
 				$key = trim(htmlspecialchars($key));
157 157
 				$value = trim(htmlspecialchars($value));
158 158
 				/*
@@ -162,35 +162,35 @@  discard block
 block discarded – undo
162 162
 				* 	$attr = array('placeholder' => 'I am a "puple"')
163 163
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
164 164
 				 */
165
-				if($value && strpos('"', $value) !== false){
165
+				if ($value && strpos('"', $value) !== false) {
166 166
 					$value = addslashes($value);
167 167
 				}
168
-				$str .= $key.' = "'.$value.'" ';
168
+				$str .= $key . ' = "' . $value . '" ';
169 169
 			}
170 170
 		}
171 171
 		//remove the space after using rtrim()
172 172
 		return rtrim($str);
173 173
 	}
174 174
 
175
-	function stringfy_vars($var){
175
+	function stringfy_vars($var) {
176 176
 		return print_r($var, true);
177 177
 	}
178 178
 
179 179
 	/**
180 180
 	*  @test
181 181
 	*/
182
-	function clean_input($str){
183
-		if(is_array($str)){
182
+	function clean_input($str) {
183
+		if (is_array($str)) {
184 184
 			$str = array_map('clean_input', $str);
185 185
 		}
186
-		else if(is_object($str)){
186
+		else if (is_object($str)) {
187 187
 			$obj = $str;
188 188
 			foreach ($str as $var => $value) {
189 189
 				$obj->$var = clean_input($value);
190 190
 			}
191 191
 			$str = $obj;
192 192
 		}
193
-		else{
193
+		else {
194 194
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
195 195
 		}
196 196
 		return $str;
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	/**
200 200
 	*  @test
201 201
 	*/
202
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
202
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
203 203
 		//get the string length
204 204
 		$len = strlen($str);
205 205
 		//if str is empty
206
-		if($len <= 0){
206
+		if ($len <= 0) {
207 207
 			return str_repeat($hiddenChar, 6);
208 208
 		}
209 209
 		//if the length is less than startCount and endCount
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 		//or startCount is negative or endCount is negative
212 212
 		//return the full string hidden
213 213
 		
214
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
214
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
215 215
 			return str_repeat($hiddenChar, $len);
216 216
 		}
217 217
 		//the start non hidden string
218 218
 		$startNonHiddenStr = substr($str, 0, $startCount);
219 219
 		//the end non hidden string
220 220
 		$endNonHiddenStr = null;
221
-		if($endCount > 0){
221
+		if ($endCount > 0) {
222 222
 			$endNonHiddenStr = substr($str, - $endCount);
223 223
 		}
224 224
 		//the hidden string
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 		return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
228 228
 	}
229 229
 	
230
-	function set_session_config(){
230
+	function set_session_config() {
231 231
 		return true;
232 232
 	}
233 233
 	
234 234
 	function & get_instance(){
235
-		if(! Controller::get_instance()){
235
+		if (!Controller::get_instance()) {
236 236
 			$c = new Controller();
237 237
 			return $c;
238 238
 		}
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Controller{
27
+	class Controller {
28 28
 		
29 29
 		/**
30 30
 		 * The name of the module if this controller belong to an module
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		 * Class constructor
49 49
 		 * @param object $logger the Log instance to use if is null will create one
50 50
 		 */
51
-		public function __construct(Log $logger = null){
51
+		public function __construct(Log $logger = null) {
52 52
 			//setting the Log instance
53 53
 			$this->setLoggerFromParamOrCreateNewInstance($logger);
54 54
 			
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 		/**
85 85
 		 * This method is used to set the module name
86 86
 		 */
87
-		protected function setModuleNameFromRouter(){
87
+		protected function setModuleNameFromRouter() {
88 88
 			//determine the current module
89
-			if(isset($this->router) && $this->router->getModule()){
89
+			if (isset($this->router) && $this->router->getModule()) {
90 90
 				$this->moduleName = $this->router->getModule();
91 91
 			}
92 92
 		}
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 		 * Set the cache using the argument otherwise will use the configuration
96 96
 		 * @param CacheInterface $cache the implementation of CacheInterface if null will use the configured
97 97
 		 */
98
-		protected function setCacheFromParamOrConfig(CacheInterface $cache = null){
98
+		protected function setCacheFromParamOrConfig(CacheInterface $cache = null) {
99 99
 			$this->logger->debug('Setting the cache handler instance');
100 100
 			//set cache handler instance
101
-			if(get_config('cache_enable', false)){
102
-				if ($cache !== null){
101
+			if (get_config('cache_enable', false)) {
102
+				if ($cache !== null) {
103 103
 					$this->cache = $cache;
104
-				} else if (isset($this->{strtolower(get_config('cache_handler'))})){
104
+				} else if (isset($this->{strtolower(get_config('cache_handler'))})) {
105 105
 					$this->cache = $this->{strtolower(get_config('cache_handler'))};
106 106
 					unset($this->{strtolower(get_config('cache_handler'))});
107 107
 				} 
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 		 * Set the Log instance using argument or create new instance
113 113
 		 * @param object $logger the Log instance if not null
114 114
 		 */
115
-		protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){
116
-			if($logger !== null){
115
+		protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null) {
116
+			if ($logger !== null) {
117 117
 	          $this->logger = $logger;
118 118
 	        }
119
-	        else{
120
-	            $this->logger =& class_loader('Log', 'classes');
119
+	        else {
120
+	            $this->logger = & class_loader('Log', 'classes');
121 121
 				$this->logger->setLogger('MainController');
122 122
 	        }
123 123
 		}
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 		 * This method is used to load the required resources for framework to work
127 127
 		 * @return void 
128 128
 		 */
129
-		private function loadRequiredResources(){
129
+		private function loadRequiredResources() {
130 130
 			$this->logger->debug('Adding the loaded classes to the super instance');
131
-			foreach (class_loaded() as $var => $class){
132
-				$this->$var =& class_loader($class);
131
+			foreach (class_loaded() as $var => $class) {
132
+				$this->$var = & class_loader($class);
133 133
 			}
134 134
 
135 135
 			$this->logger->debug('Loading the required classes into super instance');
136
-			$this->eventdispatcher =& class_loader('EventDispatcher', 'classes');
137
-			$this->loader =& class_loader('Loader', 'classes');
138
-			$this->lang =& class_loader('Lang', 'classes');
139
-			$this->request =& class_loader('Request', 'classes');
136
+			$this->eventdispatcher = & class_loader('EventDispatcher', 'classes');
137
+			$this->loader = & class_loader('Loader', 'classes');
138
+			$this->lang = & class_loader('Lang', 'classes');
139
+			$this->request = & class_loader('Request', 'classes');
140 140
 			//dispatch the request instance created event
141 141
 			$this->eventdispatcher->dispatch('REQUEST_CREATED');
142
-			$this->response =& class_loader('Response', 'classes', 'classes');
142
+			$this->response = & class_loader('Response', 'classes', 'classes');
143 143
 		}
144 144
 
145 145
 	}
Please login to merge, or discard this patch.
core/classes/Database.php 1 patch
Spacing   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -23,165 +23,165 @@  discard block
 block discarded – undo
23 23
    * along with this program; if not, write to the Free Software
24 24
    * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
   */
26
-  class Database{
26
+  class Database {
27 27
 	
28 28
 	/**
29 29
 	 * The PDO instance
30 30
 	 * @var object
31 31
 	*/
32
-    private $pdo                 = null;
32
+    private $pdo = null;
33 33
     
34 34
 	/**
35 35
 	 * The database name used for the application
36 36
 	 * @var string
37 37
 	*/
38
-	private $databaseName        = null;
38
+	private $databaseName = null;
39 39
     
40 40
 	/**
41 41
 	 * The SQL SELECT statment
42 42
 	 * @var string
43 43
 	*/
44
-	private $select              = '*';
44
+	private $select = '*';
45 45
 	
46 46
 	/**
47 47
 	 * The SQL FROM statment
48 48
 	 * @var string
49 49
 	*/
50
-    private $from                = null;
50
+    private $from = null;
51 51
 	
52 52
 	/**
53 53
 	 * The SQL WHERE statment
54 54
 	 * @var string
55 55
 	*/
56
-    private $where               = null;
56
+    private $where = null;
57 57
 	
58 58
 	/**
59 59
 	 * The SQL LIMIT statment
60 60
 	 * @var string
61 61
 	*/
62
-    private $limit               = null;
62
+    private $limit = null;
63 63
 	
64 64
 	/**
65 65
 	 * The SQL JOIN statment
66 66
 	 * @var string
67 67
 	*/
68
-    private $join                = null;
68
+    private $join = null;
69 69
 	
70 70
 	/**
71 71
 	 * The SQL ORDER BY statment
72 72
 	 * @var string
73 73
 	*/
74
-    private $orderBy             = null;
74
+    private $orderBy = null;
75 75
 	
76 76
 	/**
77 77
 	 * The SQL GROUP BY statment
78 78
 	 * @var string
79 79
 	*/
80
-    private $groupBy             = null;
80
+    private $groupBy = null;
81 81
 	
82 82
 	/**
83 83
 	 * The SQL HAVING statment
84 84
 	 * @var string
85 85
 	*/
86
-    private $having              = null;
86
+    private $having = null;
87 87
 	
88 88
 	/**
89 89
 	 * The number of rows returned by the last query
90 90
 	 * @var int
91 91
 	*/
92
-    private $numRows             = 0;
92
+    private $numRows = 0;
93 93
 	
94 94
 	/**
95 95
 	 * The last insert id for the primary key column that have auto increment or sequence
96 96
 	 * @var mixed
97 97
 	*/
98
-    private $insertId            = null;
98
+    private $insertId = null;
99 99
 	
100 100
 	/**
101 101
 	 * The full SQL query statment after build for each command
102 102
 	 * @var string
103 103
 	*/
104
-    private $query               = null;
104
+    private $query = null;
105 105
 	
106 106
 	/**
107 107
 	 * The error returned for the last query
108 108
 	 * @var string
109 109
 	*/
110
-    private $error               = null;
110
+    private $error = null;
111 111
 	
112 112
 	/**
113 113
 	 * The result returned for the last query
114 114
 	 * @var mixed
115 115
 	*/
116
-    private $result              = array();
116
+    private $result = array();
117 117
 	
118 118
 	/**
119 119
 	 * The prefix used in each database table
120 120
 	 * @var string
121 121
 	*/
122
-    private $prefix              = null;
122
+    private $prefix = null;
123 123
 	
124 124
 	/**
125 125
 	 * The list of SQL valid operators
126 126
 	 * @var array
127 127
 	*/
128
-    private $operatorList        = array('=','!=','<','>','<=','>=','<>');
128
+    private $operatorList = array('=', '!=', '<', '>', '<=', '>=', '<>');
129 129
     
130 130
 	/**
131 131
 	 * The cache default time to live in second. 0 means no need to use the cache feature
132 132
 	 * @var int
133 133
 	*/
134
-	private $cacheTtl              = 0;
134
+	private $cacheTtl = 0;
135 135
 	
136 136
 	/**
137 137
 	 * The cache current time to live. 0 means no need to use the cache feature
138 138
 	 * @var int
139 139
 	*/
140
-    private $temporaryCacheTtl   = 0;
140
+    private $temporaryCacheTtl = 0;
141 141
 	
142 142
 	/**
143 143
 	 * The number of executed query for the current request
144 144
 	 * @var int
145 145
 	*/
146
-    private $queryCount          = 0;
146
+    private $queryCount = 0;
147 147
 	
148 148
 	/**
149 149
 	 * The default data to be used in the statments query INSERT, UPDATE
150 150
 	 * @var array
151 151
 	*/
152
-    private $data                = array();
152
+    private $data = array();
153 153
 	
154 154
 	/**
155 155
 	 * The database configuration
156 156
 	 * @var array
157 157
 	*/
158
-    private $config              = array();
158
+    private $config = array();
159 159
 	
160 160
 	/**
161 161
 	 * The logger instance
162 162
 	 * @var Log
163 163
 	 */
164
-    private $logger              = null;
164
+    private $logger = null;
165 165
 
166 166
 
167 167
     /**
168 168
     * The cache instance
169 169
     * @var CacheInterface
170 170
     */
171
-    private $cacheInstance       = null;
171
+    private $cacheInstance = null;
172 172
 
173 173
      /**
174 174
     * The benchmark instance
175 175
     * @var Benchmark
176 176
     */
177
-    private $benchmarkInstance   = null;
177
+    private $benchmarkInstance = null;
178 178
 
179 179
 
180 180
     /**
181 181
      * Construct new database
182 182
      * @param array $overwriteConfig the config to overwrite with the config set in database.php
183 183
      */
184
-    public function __construct($overwriteConfig = array()){
184
+    public function __construct($overwriteConfig = array()) {
185 185
         //Set Log instance to use
186 186
         $this->setLoggerFromParamOrCreateNewInstance(null);
187 187
 
@@ -197,23 +197,23 @@  discard block
 block discarded – undo
197 197
      * This is used to connect to database
198 198
      * @return bool 
199 199
      */
200
-    public function connect(){
200
+    public function connect() {
201 201
       $config = $this->getDatabaseConfiguration();
202
-      if (! empty($config)){
203
-        try{
202
+      if (!empty($config)) {
203
+        try {
204 204
             $this->pdo = new PDO($this->getDsnFromDriver(), $config['username'], $config['password']);
205 205
             $this->pdo->exec("SET NAMES '" . $config['charset'] . "' COLLATE '" . $config['collation'] . "'");
206 206
             $this->pdo->exec("SET CHARACTER SET '" . $config['charset'] . "'");
207 207
             $this->pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
208 208
             return true;
209 209
           }
210
-          catch (PDOException $e){
210
+          catch (PDOException $e) {
211 211
             $this->logger->fatal($e->getMessage());
212 212
             show_error('Cannot connect to Database.');
213 213
             return false;
214 214
           }
215 215
       }
216
-      else{
216
+      else {
217 217
         show_error('Database configuration is not set.');
218 218
         return false;
219 219
       }
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
      * @param  string|array $table the table name or array of table list
225 225
      * @return object        the current Database instance
226 226
      */
227
-    public function from($table){
228
-      if (is_array($table)){
227
+    public function from($table) {
228
+      if (is_array($table)) {
229 229
         $froms = '';
230
-        foreach($table as $key){
230
+        foreach ($table as $key) {
231 231
           $froms .= $this->prefix . $key . ', ';
232 232
         }
233 233
         $this->from = rtrim($froms, ', ');
234 234
       }
235
-      else{
235
+      else {
236 236
         $this->from = $this->prefix . $table;
237 237
       }
238 238
       return $this;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @param  string|array $fields the field name or array of field list
244 244
      * @return object        the current Database instance
245 245
      */
246
-    public function select($fields){
246
+    public function select($fields) {
247 247
       $select = (is_array($fields) ? implode(', ', $fields) : $fields);
248 248
       $this->select = ($this->select == '*' ? $select : $this->select . ', ' . $select);
249 249
       return $this;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      * @param  string $field the field name to distinct
255 255
      * @return object        the current Database instance
256 256
      */
257
-    public function distinct($field){
257
+    public function distinct($field) {
258 258
       $distinct = ' DISTINCT ' . $field;
259 259
       $this->select = ($this->select == '*' ? $distinct : $this->select . ', ' . $distinct);
260 260
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
      * @param  string $name  if is not null represent the alias used for this field in the result
268 268
      * @return object        the current Database instance
269 269
      */
270
-    public function max($field, $name = null){
270
+    public function max($field, $name = null) {
271 271
       $func = 'MAX(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
272 272
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
273 273
       return $this;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      * @param  string $name  if is not null represent the alias used for this field in the result
280 280
      * @return object        the current Database instance
281 281
      */
282
-    public function min($field, $name = null){
282
+    public function min($field, $name = null) {
283 283
       $func = 'MIN(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
284 284
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
285 285
       return $this;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @param  string $name  if is not null represent the alias used for this field in the result
292 292
      * @return object        the current Database instance
293 293
      */
294
-    public function sum($field, $name = null){
294
+    public function sum($field, $name = null) {
295 295
       $func = 'SUM(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
296 296
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
297 297
       return $this;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * @param  string $name  if is not null represent the alias used for this field in the result
304 304
      * @return object        the current Database instance
305 305
      */
306
-    public function count($field = '*', $name = null){
306
+    public function count($field = '*', $name = null) {
307 307
       $func = 'COUNT(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
308 308
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
309 309
       return $this;
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      * @param  string $name  if is not null represent the alias used for this field in the result
316 316
      * @return object        the current Database instance
317 317
      */
318
-    public function avg($field, $name = null){
318
+    public function avg($field, $name = null) {
319 319
       $func = 'AVG(' . $field . ')' . (!is_null($name) ? ' AS ' . $name : '');
320 320
       $this->select = ($this->select == '*' ? $func : $this->select . ', ' . $func);
321 321
       return $this;
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
      * @param  string $type   the type of join (INNER, LEFT, RIGHT)
331 331
      * @return object        the current Database instance
332 332
      */
333
-    public function join($table, $field1 = null, $op = null, $field2 = null, $type = ''){
333
+    public function join($table, $field1 = null, $op = null, $field2 = null, $type = '') {
334 334
       $on = $field1;
335 335
       $table = $this->prefix . $table;
336
-      if (! is_null($op)){
337
-        $on = (! in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
336
+      if (!is_null($op)) {
337
+        $on = (!in_array($op, $this->operatorList) ? $this->prefix . $field1 . ' = ' . $this->prefix . $op : $this->prefix . $field1 . ' ' . $op . ' ' . $this->prefix . $field2);
338 338
       }
339
-      if (empty($this->join)){
339
+      if (empty($this->join)) {
340 340
         $this->join = ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
341 341
       }
342
-      else{
342
+      else {
343 343
         $this->join = $this->join . ' ' . $type . 'JOIN' . ' ' . $table . ' ON ' . $on;
344 344
       }
345 345
       return $this;
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      * @see  Database::join()
351 351
      * @return object        the current Database instance
352 352
      */
353
-    public function innerJoin($table, $field1, $op = null, $field2 = ''){
353
+    public function innerJoin($table, $field1, $op = null, $field2 = '') {
354 354
       return $this->join($table, $field1, $op, $field2, 'INNER ');
355 355
     }
356 356
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      * @see  Database::join()
360 360
      * @return object        the current Database instance
361 361
      */
362
-    public function leftJoin($table, $field1, $op = null, $field2 = ''){
362
+    public function leftJoin($table, $field1, $op = null, $field2 = '') {
363 363
       return $this->join($table, $field1, $op, $field2, 'LEFT ');
364 364
 	}
365 365
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
      * @see  Database::join()
369 369
      * @return object        the current Database instance
370 370
      */
371
-    public function rightJoin($table, $field1, $op = null, $field2 = ''){
371
+    public function rightJoin($table, $field1, $op = null, $field2 = '') {
372 372
       return $this->join($table, $field1, $op, $field2, 'RIGHT ');
373 373
     }
374 374
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
      * @see  Database::join()
378 378
      * @return object        the current Database instance
379 379
      */
380
-    public function fullOuterJoin($table, $field1, $op = null, $field2 = ''){
380
+    public function fullOuterJoin($table, $field1, $op = null, $field2 = '') {
381 381
     	return $this->join($table, $field1, $op, $field2, 'FULL OUTER ');
382 382
     }
383 383
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      * @see  Database::join()
387 387
      * @return object        the current Database instance
388 388
      */
389
-    public function leftOuterJoin($table, $field1, $op = null, $field2 = ''){
389
+    public function leftOuterJoin($table, $field1, $op = null, $field2 = '') {
390 390
       return $this->join($table, $field1, $op, $field2, 'LEFT OUTER ');
391 391
     }
392 392
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      * @see  Database::join()
396 396
      * @return object        the current Database instance
397 397
      */
398
-    public function rightOuterJoin($table, $field1, $op = null, $field2 = ''){
398
+    public function rightOuterJoin($table, $field1, $op = null, $field2 = '') {
399 399
       return $this->join($table, $field1, $op, $field2, 'RIGHT OUTER ');
400 400
     }
401 401
 
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
406 406
      * @return object        the current Database instance
407 407
      */
408
-    public function whereIsNull($field, $andOr = 'AND'){
409
-      if (is_array($field)){
410
-        foreach($field as $f){
408
+    public function whereIsNull($field, $andOr = 'AND') {
409
+      if (is_array($field)) {
410
+        foreach ($field as $f) {
411 411
         	$this->whereIsNull($f, $andOr);
412 412
         }
413 413
       }
414
-      else{
415
-           $this->setWhereStr($field.' IS NULL ', $andOr);
414
+      else {
415
+           $this->setWhereStr($field . ' IS NULL ', $andOr);
416 416
       }
417 417
       return $this;
418 418
     }
@@ -423,14 +423,14 @@  discard block
 block discarded – undo
423 423
      * @param  string $andOr the separator type used 'AND', 'OR', etc.
424 424
      * @return object        the current Database instance
425 425
      */
426
-    public function whereIsNotNull($field, $andOr = 'AND'){
427
-      if (is_array($field)){
428
-        foreach($field as $f){
426
+    public function whereIsNotNull($field, $andOr = 'AND') {
427
+      if (is_array($field)) {
428
+        foreach ($field as $f) {
429 429
           $this->whereIsNotNull($f, $andOr);
430 430
         }
431 431
       }
432
-      else{
433
-          $this->setWhereStr($field.' IS NOT NULL ', $andOr);
432
+      else {
433
+          $this->setWhereStr($field . ' IS NOT NULL ', $andOr);
434 434
       }
435 435
       return $this;
436 436
     }
@@ -445,13 +445,13 @@  discard block
 block discarded – undo
445 445
      * @param  boolean $escape whether to escape or not the $val
446 446
      * @return object        the current Database instance
447 447
      */
448
-    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true){
448
+    public function where($where, $op = null, $val = null, $type = '', $andOr = 'AND', $escape = true) {
449 449
       $whereStr = '';
450
-      if (is_array($where)){
450
+      if (is_array($where)) {
451 451
         $whereStr = $this->getWhereStrIfIsArray($where, $type, $andOr, $escape);
452 452
       }
453
-      else{
454
-        if (is_array($op)){
453
+      else {
454
+        if (is_array($op)) {
455 455
           $whereStr = $this->getWhereStrIfOperatorIsArray($where, $op, $type, $escape);
456 456
         } else {
457 457
           $whereStr = $this->getWhereStrForOperator($where, $op, $val, $type, $escape = true);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
      * @see  Database::where()
467 467
      * @return object        the current Database instance
468 468
      */
469
-    public function orWhere($where, $op = null, $val = null, $escape = true){
469
+    public function orWhere($where, $op = null, $val = null, $escape = true) {
470 470
       return $this->where($where, $op, $val, '', 'OR', $escape);
471 471
     }
472 472
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
      * @see  Database::where()
477 477
      * @return object        the current Database instance
478 478
      */
479
-    public function notWhere($where, $op = null, $val = null, $escape = true){
479
+    public function notWhere($where, $op = null, $val = null, $escape = true) {
480 480
       return $this->where($where, $op, $val, 'NOT ', 'AND', $escape);
481 481
     }
482 482
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
      * @see  Database::where()
486 486
      * @return object        the current Database instance
487 487
      */
488
-    public function orNotWhere($where, $op = null, $val = null, $escape = true){
488
+    public function orNotWhere($where, $op = null, $val = null, $escape = true) {
489 489
     	return $this->where($where, $op, $val, 'NOT ', 'OR', $escape);
490 490
     }
491 491
 
@@ -495,15 +495,15 @@  discard block
 block discarded – undo
495 495
      * @param  string $andOr the multiple conditions separator (AND, OR, etc.)
496 496
      * @return object        the current Database instance
497 497
      */
498
-    public function groupStart($type = '', $andOr = ' AND'){
499
-      if (empty($this->where)){
498
+    public function groupStart($type = '', $andOr = ' AND') {
499
+      if (empty($this->where)) {
500 500
         $this->where = $type . ' (';
501 501
       }
502
-      else{
503
-          if (substr($this->where, -1) == '('){
502
+      else {
503
+          if (substr($this->where, -1) == '(') {
504 504
             $this->where .= $type . ' (';
505 505
           }
506
-          else{
506
+          else {
507 507
           	$this->where .= $andOr . ' ' . $type . ' (';
508 508
           }
509 509
       }
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
      * @see  Database::groupStart()
516 516
      * @return object        the current Database instance
517 517
      */
518
-    public function notGroupStart(){
518
+    public function notGroupStart() {
519 519
       return $this->groupStart('NOT');
520 520
     }
521 521
 
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
      * @see  Database::groupStart()
525 525
      * @return object        the current Database instance
526 526
      */
527
-    public function orGroupStart(){
527
+    public function orGroupStart() {
528 528
       return $this->groupStart('', ' OR');
529 529
     }
530 530
 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
      * @see  Database::groupStart()
534 534
      * @return object        the current Database instance
535 535
      */
536
-    public function orNotGroupStart(){
536
+    public function orNotGroupStart() {
537 537
       return $this->groupStart('NOT', ' OR');
538 538
     }
539 539
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      * Close the parenthesis for the grouped SQL
542 542
      * @return object        the current Database instance
543 543
      */
544
-    public function groupEnd(){
544
+    public function groupEnd() {
545 545
       $this->where .= ')';
546 546
       return $this;
547 547
     }
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
      * @param  boolean $escape whether to escape or not the values
556 556
      * @return object        the current Database instance
557 557
      */
558
-    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true){
558
+    public function in($field, array $keys, $type = '', $andOr = 'AND', $escape = true) {
559 559
       $_keys = array();
560
-      foreach ($keys as $k => $v){
561
-        if (is_null($v)){
560
+      foreach ($keys as $k => $v) {
561
+        if (is_null($v)) {
562 562
           $v = '';
563 563
         }
564 564
         $_keys[] = (is_numeric($v) ? $v : $this->escape($v, $escape));
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
      * @see  Database::in()
575 575
      * @return object        the current Database instance
576 576
      */
577
-    public function notIn($field, array $keys, $escape = true){
577
+    public function notIn($field, array $keys, $escape = true) {
578 578
       return $this->in($field, $keys, 'NOT ', 'AND', $escape);
579 579
     }
580 580
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
      * @see  Database::in()
584 584
      * @return object        the current Database instance
585 585
      */
586
-    public function orIn($field, array $keys, $escape = true){
586
+    public function orIn($field, array $keys, $escape = true) {
587 587
       return $this->in($field, $keys, '', 'OR', $escape);
588 588
     }
589 589
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
      * @see  Database::in()
593 593
      * @return object        the current Database instance
594 594
      */
595
-    public function orNotIn($field, array $keys, $escape = true){
595
+    public function orNotIn($field, array $keys, $escape = true) {
596 596
       return $this->in($field, $keys, 'NOT ', 'OR', $escape);
597 597
     }
598 598
 
@@ -606,11 +606,11 @@  discard block
 block discarded – undo
606 606
      * @param  boolean $escape whether to escape or not the values
607 607
      * @return object        the current Database instance
608 608
      */
609
-    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true){
610
-      if (is_null($value1)){
609
+    public function between($field, $value1, $value2, $type = '', $andOr = 'AND', $escape = true) {
610
+      if (is_null($value1)) {
611 611
         $value1 = '';
612 612
       }
613
-      if (is_null($value2)){
613
+      if (is_null($value2)) {
614 614
         $value2 = '';
615 615
       }
616 616
       $whereStr = $field . ' ' . $type . ' BETWEEN ' . $this->escape($value1, $escape) . ' AND ' . $this->escape($value2, $escape);
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
      * @see  Database::between()
624 624
      * @return object        the current Database instance
625 625
      */
626
-    public function notBetween($field, $value1, $value2, $escape = true){
626
+    public function notBetween($field, $value1, $value2, $escape = true) {
627 627
       return $this->between($field, $value1, $value2, 'NOT ', 'AND', $escape);
628 628
     }
629 629
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @see  Database::between()
633 633
      * @return object        the current Database instance
634 634
      */
635
-    public function orBetween($field, $value1, $value2, $escape = true){
635
+    public function orBetween($field, $value1, $value2, $escape = true) {
636 636
       return $this->between($field, $value1, $value2, '', 'OR', $escape);
637 637
     }
638 638
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
      * @see  Database::between()
642 642
      * @return object        the current Database instance
643 643
      */
644
-    public function orNotBetween($field, $value1, $value2, $escape = true){
644
+    public function orNotBetween($field, $value1, $value2, $escape = true) {
645 645
       return $this->between($field, $value1, $value2, 'NOT ', 'OR', $escape);
646 646
     }
647 647
 
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
      * @param  boolean $escape whether to escape or not the values
655 655
      * @return object        the current Database instance
656 656
      */
657
-    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true){
658
-      if (empty($data)){
657
+    public function like($field, $data, $type = '', $andOr = 'AND', $escape = true) {
658
+      if (empty($data)) {
659 659
         $data = '';
660 660
       }
661 661
       $this->setWhereStr($field . ' ' . $type . ' LIKE ' . ($this->escape($data, $escape)), $andOr);
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
      * @see  Database::like()
668 668
      * @return object        the current Database instance
669 669
      */
670
-    public function orLike($field, $data, $escape = true){
670
+    public function orLike($field, $data, $escape = true) {
671 671
       return $this->like($field, $data, '', 'OR', $escape);
672 672
     }
673 673
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
      * @see  Database::like()
677 677
      * @return object        the current Database instance
678 678
      */
679
-    public function notLike($field, $data, $escape = true){
679
+    public function notLike($field, $data, $escape = true) {
680 680
       return $this->like($field, $data, 'NOT ', 'AND', $escape);
681 681
     }
682 682
 
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
      * @see  Database::like()
686 686
      * @return object        the current Database instance
687 687
      */
688
-    public function orNotLike($field, $data, $escape = true){
688
+    public function orNotLike($field, $data, $escape = true) {
689 689
       return $this->like($field, $data, 'NOT ', 'OR', $escape);
690 690
     }
691 691
 
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
      * @param  int $limitEnd the limit count
697 697
      * @return object        the current Database instance
698 698
      */
699
-    public function limit($limit, $limitEnd = null){
700
-      if (empty($limit)){
699
+    public function limit($limit, $limitEnd = null) {
700
+      if (empty($limit)) {
701 701
         return;
702 702
       }
703
-      if (! is_null($limitEnd)){
703
+      if (!is_null($limitEnd)) {
704 704
         $this->limit = $limit . ', ' . $limitEnd;
705 705
       }
706
-      else{
706
+      else {
707 707
         $this->limit = $limit;
708 708
       }
709 709
       return $this;
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
      * @param  string $orderDir the order direction (ASC or DESC)
716 716
      * @return object        the current Database instance
717 717
      */
718
-    public function orderBy($orderBy, $orderDir = ' ASC'){
719
-        if (stristr($orderBy, ' ') || $orderBy == 'rand()'){
718
+    public function orderBy($orderBy, $orderDir = ' ASC') {
719
+        if (stristr($orderBy, ' ') || $orderBy == 'rand()') {
720 720
           $this->orderBy = empty($this->orderBy) ? $orderBy : $this->orderBy . ', ' . $orderBy;
721 721
         }
722
-        else{
722
+        else {
723 723
           $this->orderBy = empty($this->orderBy) ? ($orderBy . ' ' 
724 724
                             . strtoupper($orderDir)) : $this->orderBy 
725 725
                             . ', ' . $orderBy . ' ' . strtoupper($orderDir);
@@ -732,11 +732,11 @@  discard block
 block discarded – undo
732 732
      * @param  string|array $field the field name used or array of field list
733 733
      * @return object        the current Database instance
734 734
      */
735
-    public function groupBy($field){
736
-      if (is_array($field)){
735
+    public function groupBy($field) {
736
+      if (is_array($field)) {
737 737
         $this->groupBy = implode(', ', $field);
738 738
       }
739
-      else{
739
+      else {
740 740
         $this->groupBy = $field;
741 741
       }
742 742
       return $this;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
      * @param  boolean $escape whether to escape or not the values
751 751
      * @return object        the current Database instance
752 752
      */
753
-    public function having($field, $op = null, $val = null, $escape = true){
754
-      if (is_array($op)){
753
+    public function having($field, $op = null, $val = null, $escape = true) {
754
+      if (is_array($op)) {
755 755
         $x = explode('?', $field);
756 756
         $w = '';
757
-        foreach($x as $k => $v){
758
-  	      if (!empty($v)){
759
-            if (! isset($op[$k])){
757
+        foreach ($x as $k => $v) {
758
+  	      if (!empty($v)) {
759
+            if (!isset($op[$k])) {
760 760
               $op[$k] = '';
761 761
             }
762 762
   	      	$w .= $v . (isset($op[$k]) ? $this->escape($op[$k], $escape) : '');
@@ -764,14 +764,14 @@  discard block
 block discarded – undo
764 764
       	}
765 765
         $this->having = $w;
766 766
       }
767
-      else if (! in_array($op, $this->operatorList)){
768
-        if (is_null($op)){
767
+      else if (!in_array($op, $this->operatorList)) {
768
+        if (is_null($op)) {
769 769
           $op = '';
770 770
         }
771 771
         $this->having = $field . ' > ' . ($this->escape($op, $escape));
772 772
       }
773
-      else{
774
-        if (is_null($val)){
773
+      else {
774
+        if (is_null($val)) {
775 775
           $val = '';
776 776
         }
777 777
         $this->having = $field . ' ' . $op . ' ' . ($this->escape($val, $escape));
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
      * Return the number of rows returned by the current query
784 784
      * @return int
785 785
      */
786
-    public function numRows(){
786
+    public function numRows() {
787 787
       return $this->numRows;
788 788
     }
789 789
 
@@ -791,15 +791,15 @@  discard block
 block discarded – undo
791 791
      * Return the last insert id value
792 792
      * @return mixed
793 793
      */
794
-    public function insertId(){
794
+    public function insertId() {
795 795
       return $this->insertId;
796 796
     }
797 797
 
798 798
     /**
799 799
      * Show an error got from the current query (SQL command synthax error, database driver returned error, etc.)
800 800
      */
801
-    public function error(){
802
-  		if ($this->error){
801
+    public function error() {
802
+  		if ($this->error) {
803 803
   			show_error('Query: "' . $this->query . '" Error: ' . $this->error, 'Database Error');
804 804
   		}
805 805
     }
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
      * If is string will determine the result type "array" or "object"
811 811
      * @return mixed       the query SQL string or the record result
812 812
      */
813
-    public function get($returnSQLQueryOrResultType = false){
813
+    public function get($returnSQLQueryOrResultType = false) {
814 814
       $this->limit = 1;
815 815
       $query = $this->getAll(true);
816
-      if ($returnSQLQueryOrResultType === true){
816
+      if ($returnSQLQueryOrResultType === true) {
817 817
         return $query;
818 818
       }
819
-      else{
820
-        return $this->query( $query, false, (($returnSQLQueryOrResultType == 'array') ? true : false) );
819
+      else {
820
+        return $this->query($query, false, (($returnSQLQueryOrResultType == 'array') ? true : false));
821 821
       }
822 822
     }
823 823
 
@@ -827,33 +827,33 @@  discard block
 block discarded – undo
827 827
      * If is string will determine the result type "array" or "object"
828 828
      * @return mixed       the query SQL string or the record result
829 829
      */
830
-    public function getAll($returnSQLQueryOrResultType = false){
830
+    public function getAll($returnSQLQueryOrResultType = false) {
831 831
       $query = 'SELECT ' . $this->select . ' FROM ' . $this->from;
832
-      if (! empty($this->join)){
832
+      if (!empty($this->join)) {
833 833
         $query .= $this->join;
834 834
       }
835 835
 	  
836
-      if (! empty($this->where)){
836
+      if (!empty($this->where)) {
837 837
         $query .= ' WHERE ' . $this->where;
838 838
       }
839 839
 
840
-      if (! empty($this->groupBy)){
840
+      if (!empty($this->groupBy)) {
841 841
         $query .= ' GROUP BY ' . $this->groupBy;
842 842
       }
843 843
 
844
-      if (! empty($this->having)){
844
+      if (!empty($this->having)) {
845 845
         $query .= ' HAVING ' . $this->having;
846 846
       }
847 847
 
848
-      if (! empty($this->orderBy)){
848
+      if (!empty($this->orderBy)) {
849 849
           $query .= ' ORDER BY ' . $this->orderBy;
850 850
       }
851 851
 
852
-      if (! empty($this->limit)){
852
+      if (!empty($this->limit)) {
853 853
       	$query .= ' LIMIT ' . $this->limit;
854 854
       }
855 855
 	  
856
-	   if ($returnSQLQueryOrResultType === true){
856
+	   if ($returnSQLQueryOrResultType === true) {
857 857
       	return $query;
858 858
       }
859 859
     	return $this->query($query, true, $returnSQLQueryOrResultType == 'array');
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
      * @param  boolean $escape  whether to escape or not the values
866 866
      * @return mixed          the insert id of the new record or null
867 867
      */
868
-    public function insert($data = array(), $escape = true){
869
-      if (empty($data) && $this->getData()){
868
+    public function insert($data = array(), $escape = true) {
869
+      if (empty($data) && $this->getData()) {
870 870
         //as when using $this->setData() the data already escaped
871 871
         $escape = false;
872 872
         $data = $this->getData();
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
       $query = 'INSERT INTO ' . $this->from . ' (' . $column . ') VALUES (' . $val . ')';
880 880
       $query = $this->query($query);
881 881
 
882
-      if ($query){
882
+      if ($query) {
883 883
         $this->insertId = $this->pdo->lastInsertId();
884 884
         return $this->insertId();
885 885
       }
@@ -892,27 +892,27 @@  discard block
 block discarded – undo
892 892
      * @param  boolean $escape  whether to escape or not the values
893 893
      * @return mixed          the update status
894 894
      */
895
-    public function update($data = array(), $escape = true){
895
+    public function update($data = array(), $escape = true) {
896 896
       $query = 'UPDATE ' . $this->from . ' SET ';
897 897
       $values = array();
898
-      if (empty($data) && $this->getData()){
898
+      if (empty($data) && $this->getData()) {
899 899
         //as when using $this->setData() the data already escaped
900 900
         $escape = false;
901 901
         $data = $this->getData();
902 902
       }
903
-      foreach ($data as $column => $val){
903
+      foreach ($data as $column => $val) {
904 904
         $values[] = $column . ' = ' . ($this->escape($val, $escape));
905 905
       }
906 906
       $query .= implode(', ', $values);
907
-      if (! empty($this->where)){
907
+      if (!empty($this->where)) {
908 908
         $query .= ' WHERE ' . $this->where;
909 909
       }
910 910
 
911
-      if (! empty($this->orderBy)){
911
+      if (!empty($this->orderBy)) {
912 912
         $query .= ' ORDER BY ' . $this->orderBy;
913 913
       }
914 914
 
915
-      if (! empty($this->limit)){
915
+      if (!empty($this->limit)) {
916 916
         $query .= ' LIMIT ' . $this->limit;
917 917
       }
918 918
       return $this->query($query);
@@ -922,22 +922,22 @@  discard block
 block discarded – undo
922 922
      * Delete the record in database
923 923
      * @return mixed the delete status
924 924
      */
925
-    public function delete(){
925
+    public function delete() {
926 926
     	$query = 'DELETE FROM ' . $this->from;
927 927
 
928
-    	if (! empty($this->where)){
928
+    	if (!empty($this->where)) {
929 929
     		$query .= ' WHERE ' . $this->where;
930 930
       	}
931 931
 
932
-    	if (! empty($this->orderBy)){
932
+    	if (!empty($this->orderBy)) {
933 933
     	  $query .= ' ORDER BY ' . $this->orderBy;
934 934
       	}
935 935
 
936
-    	if (! empty($this->limit)){
936
+    	if (!empty($this->limit)) {
937 937
     		$query .= ' LIMIT ' . $this->limit;
938 938
       	}
939 939
 
940
-    	if ($query == 'DELETE FROM ' . $this->from && $this->config['driver'] != 'sqlite'){  
940
+    	if ($query == 'DELETE FROM ' . $this->from && $this->config['driver'] != 'sqlite') {  
941 941
     		$query = 'TRUNCATE TABLE ' . $this->from;
942 942
       }
943 943
     	return $this->query($query);
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
      * @param integer $ttl the cache time to live in second
949 949
      * @return object        the current Database instance
950 950
      */
951
-    public function setCache($ttl = 0){
952
-      if ($ttl > 0){
951
+    public function setCache($ttl = 0) {
952
+      if ($ttl > 0) {
953 953
         $this->cacheTtl = $ttl;
954 954
 		    $this->temporaryCacheTtl = $ttl;
955 955
       }
@@ -961,8 +961,8 @@  discard block
 block discarded – undo
961 961
 	 * @param  integer $ttl the cache time to live in second
962 962
 	 * @return object        the current Database instance
963 963
 	 */
964
-	public function cached($ttl = 0){
965
-      if ($ttl > 0){
964
+	public function cached($ttl = 0) {
965
+      if ($ttl > 0) {
966 966
         $this->temporaryCacheTtl = $ttl;
967 967
       }
968 968
 	  return $this;
@@ -974,9 +974,9 @@  discard block
 block discarded – undo
974 974
      * @param boolean $escaped whether we can do escape of not 
975 975
      * @return mixed       the data after escaped or the same data if not
976 976
      */
977
-    public function escape($data, $escaped = true){
978
-      if ($escaped){
979
-        if (! $this->pdo){
977
+    public function escape($data, $escaped = true) {
978
+      if ($escaped) {
979
+        if (!$this->pdo) {
980 980
           $this->connect();
981 981
         }
982 982
         return $this->pdo->quote(trim($data)); 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      * Return the number query executed count for the current request
989 989
      * @return int
990 990
      */
991
-    public function queryCount(){
991
+    public function queryCount() {
992 992
       return $this->queryCount;
993 993
     }
994 994
 
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
      * Return the current query SQL string
997 997
      * @return string
998 998
      */
999
-    public function getQuery(){
999
+    public function getQuery() {
1000 1000
       return $this->query;
1001 1001
     }
1002 1002
 
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      * Return the application database name
1005 1005
      * @return string
1006 1006
      */
1007
-    public function getDatabaseName(){
1007
+    public function getDatabaseName() {
1008 1008
       return $this->databaseName;
1009 1009
     }
1010 1010
 
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
      * Return the database configuration
1013 1013
      * @return array
1014 1014
      */
1015
-    public  function getDatabaseConfiguration(){
1015
+    public  function getDatabaseConfiguration() {
1016 1016
       return $this->config;
1017 1017
     }
1018 1018
 
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
      * set the database configuration
1021 1021
      * @param array $config the configuration
1022 1022
      */
1023
-    public function setDatabaseConfiguration(array $config){
1023
+    public function setDatabaseConfiguration(array $config) {
1024 1024
       $this->config = array_merge($this->config, $config);
1025 1025
       $this->prefix = $this->config['prefix'];
1026 1026
       $this->databaseName = $this->config['database'];
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
      * Return the PDO instance
1033 1033
      * @return PDO
1034 1034
      */
1035
-    public function getPdo(){
1035
+    public function getPdo() {
1036 1036
       return $this->pdo;
1037 1037
     }
1038 1038
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
      * Set the PDO instance
1041 1041
      * @param PDO $pdo the pdo object
1042 1042
      */
1043
-    public function setPdo(PDO $pdo){
1043
+    public function setPdo(PDO $pdo) {
1044 1044
       $this->pdo = $pdo;
1045 1045
       return $this;
1046 1046
     }
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
      * Return the Log instance
1051 1051
      * @return Log
1052 1052
      */
1053
-    public function getLogger(){
1053
+    public function getLogger() {
1054 1054
       return $this->logger;
1055 1055
     }
1056 1056
 
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
      * Set the log instance
1059 1059
      * @param Log $logger the log object
1060 1060
      */
1061
-    public function setLogger($logger){
1061
+    public function setLogger($logger) {
1062 1062
       $this->logger = $logger;
1063 1063
       return $this;
1064 1064
     }
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
      * Return the cache instance
1068 1068
      * @return CacheInterface
1069 1069
      */
1070
-    public function getCacheInstance(){
1070
+    public function getCacheInstance() {
1071 1071
       return $this->cacheInstance;
1072 1072
     }
1073 1073
 
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
      * Set the cache instance
1076 1076
      * @param CacheInterface $cache the cache object
1077 1077
      */
1078
-    public function setCacheInstance($cache){
1078
+    public function setCacheInstance($cache) {
1079 1079
       $this->cacheInstance = $cache;
1080 1080
       return $this;
1081 1081
     }
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
      * Return the benchmark instance
1085 1085
      * @return Benchmark
1086 1086
      */
1087
-    public function getBenchmark(){
1087
+    public function getBenchmark() {
1088 1088
       return $this->benchmarkInstance;
1089 1089
     }
1090 1090
 
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
      * Set the benchmark instance
1093 1093
      * @param Benchmark $cache the cache object
1094 1094
      */
1095
-    public function setBenchmark($benchmark){
1095
+    public function setBenchmark($benchmark) {
1096 1096
       $this->benchmarkInstance = $benchmark;
1097 1097
       return $this;
1098 1098
     }
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
      * Return the data to be used for insert, update, etc.
1102 1102
      * @return array
1103 1103
      */
1104
-    public function getData(){
1104
+    public function getData() {
1105 1105
       return $this->data;
1106 1106
     }
1107 1107
 
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
      * @param boolean $escape whether to escape or not the $value
1113 1113
      * @return object        the current Database instance
1114 1114
      */
1115
-    public function setData($key, $value, $escape = true){
1115
+    public function setData($key, $value, $escape = true) {
1116 1116
       $this->data[$key] = $this->escape($value, $escape);
1117 1117
       return $this;
1118 1118
     }
@@ -1125,14 +1125,14 @@  discard block
 block discarded – undo
1125 1125
      * @param  boolean $array return the result as array
1126 1126
      * @return mixed         the query result
1127 1127
      */
1128
-    public function query($query, $all = true, $array = false){
1128
+    public function query($query, $all = true, $array = false) {
1129 1129
       $this->reset();
1130 1130
       $query = $this->transformPreparedQuery($query, $all);
1131 1131
       $this->query = preg_replace('/\s\s+|\t\t+/', ' ', trim($query));
1132 1132
       
1133 1133
       $isSqlSELECTQuery = stristr($this->query, 'SELECT');
1134 1134
 
1135
-      $this->logger->info('Execute SQL query ['.$this->query.'], return type: ' . ($array?'ARRAY':'OBJECT') .', return as list: ' . (is_bool($all) && $all ? 'YES':'NO'));
1135
+      $this->logger->info('Execute SQL query [' . $this->query . '], return type: ' . ($array ? 'ARRAY' : 'OBJECT') . ', return as list: ' . (is_bool($all) && $all ? 'YES' : 'NO'));
1136 1136
       //cache expire time
1137 1137
       $cacheExpire = $this->temporaryCacheTtl;
1138 1138
       
@@ -1148,15 +1148,15 @@  discard block
 block discarded – undo
1148 1148
       //if can use cache feature for this query
1149 1149
       $dbCacheStatus = $cacheEnable && $cacheExpire > 0;
1150 1150
     
1151
-      if ($dbCacheStatus && $isSqlSELECTQuery){
1151
+      if ($dbCacheStatus && $isSqlSELECTQuery) {
1152 1152
           $this->logger->info('The cache is enabled for this query, try to get result from cache'); 
1153 1153
           $cacheContent = $this->getCacheContentForQuery($query, $all, $array);  
1154 1154
       }
1155 1155
       
1156
-      if ( !$cacheContent){
1156
+      if (!$cacheContent) {
1157 1157
         $sqlQuery = $this->runSqlQuery($query, $all, $array);
1158
-        if (is_object($sqlQuery)){
1159
-          if ($isSqlSELECTQuery){
1158
+        if (is_object($sqlQuery)) {
1159
+          if ($isSqlSELECTQuery) {
1160 1160
             $this->setQueryResultForSelect($sqlQuery, $all, $array);
1161 1161
             $this->setCacheContentForQuery(
1162 1162
                                             $this->query, 
@@ -1166,20 +1166,20 @@  discard block
 block discarded – undo
1166 1166
                                             $this->temporaryCacheTtl
1167 1167
                                           );
1168 1168
           }
1169
-          else{
1169
+          else {
1170 1170
               $this->setQueryResultForNonSelect($sqlQuery);
1171
-              if (! $this->result){
1171
+              if (!$this->result) {
1172 1172
                 $this->setQueryError();
1173 1173
               }
1174 1174
           }
1175 1175
         }
1176
-      } else if ($isSqlSELECTQuery){
1177
-          $this->logger->info('The result for query [' .$this->query. '] already cached use it');
1176
+      } else if ($isSqlSELECTQuery) {
1177
+          $this->logger->info('The result for query [' . $this->query . '] already cached use it');
1178 1178
           $this->result = $cacheContent;
1179 1179
           $this->numRows = count($this->result);
1180 1180
       }
1181 1181
       $this->queryCount++;
1182
-      if (! $this->result){
1182
+      if (!$this->result) {
1183 1183
         $this->logger->info('No result where found for the query [' . $query . ']');
1184 1184
       }
1185 1185
       return $this->result;
@@ -1190,12 +1190,12 @@  discard block
 block discarded – undo
1190 1190
      * Set the Log instance using argument or create new instance
1191 1191
      * @param object $logger the Log instance if not null
1192 1192
      */
1193
-    protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null){
1194
-      if ($logger !== null){
1193
+    protected function setLoggerFromParamOrCreateNewInstance(Log $logger = null) {
1194
+      if ($logger !== null) {
1195 1195
         $this->logger = $logger;
1196 1196
       }
1197
-      else{
1198
-          $this->logger =& class_loader('Log', 'classes');
1197
+      else {
1198
+          $this->logger = & class_loader('Log', 'classes');
1199 1199
           $this->logger->setLogger('Library::Database');
1200 1200
       }
1201 1201
     }
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * Setting the database configuration using the configuration file
1205 1205
     * @param array $overwriteConfig the additional configuration to overwrite with the existing one
1206 1206
     */
1207
-    protected function setDatabaseConfigurationFromConfigFile(array $overwriteConfig = array()){
1207
+    protected function setDatabaseConfigurationFromConfigFile(array $overwriteConfig = array()) {
1208 1208
         $db = array();
1209
-        if (file_exists(CONFIG_PATH . 'database.php')){
1209
+        if (file_exists(CONFIG_PATH . 'database.php')) {
1210 1210
             //here don't use require_once because somewhere user can create database instance directly
1211 1211
             require CONFIG_PATH . 'database.php';
1212 1212
         }
1213 1213
           
1214
-        if (! empty($overwriteConfig)){
1214
+        if (!empty($overwriteConfig)) {
1215 1215
           $db = array_merge($db, $overwriteConfig);
1216 1216
         }
1217 1217
         $config = array(
@@ -1233,9 +1233,9 @@  discard block
 block discarded – undo
1233 1233
      * This method is used to get the PDO DSN string using th configured driver
1234 1234
      * @return string the DSN string
1235 1235
      */
1236
-    protected function getDsnFromDriver(){
1236
+    protected function getDsnFromDriver() {
1237 1237
       $config = $this->getDatabaseConfiguration();
1238
-      if (! empty($config)){
1238
+      if (!empty($config)) {
1239 1239
             $driverDsnMap = array(
1240 1240
                                     'mysql' => 'mysql:host=' . $config['hostname'] . ';' 
1241 1241
                                                 . (($config['port']) != '' ? 'port=' . $config['port'] . ';' : '') 
@@ -1257,10 +1257,10 @@  discard block
 block discarded – undo
1257 1257
      * Set the database server port configuration using the current hostname like localhost:3309 
1258 1258
      * @return void
1259 1259
      */
1260
-    protected function setPortConfigurationFromHostname(){
1261
-      if (strstr($this->config['hostname'], ':')){
1260
+    protected function setPortConfigurationFromHostname() {
1261
+      if (strstr($this->config['hostname'], ':')) {
1262 1262
         $p = explode(':', $this->config['hostname']);
1263
-        if (count($p) >= 2){
1263
+        if (count($p) >= 2) {
1264 1264
           $this->setDatabaseConfiguration(array(
1265 1265
             'hostname' => $p[0],
1266 1266
             'port' => $p[1]
@@ -1275,15 +1275,15 @@  discard block
 block discarded – undo
1275 1275
      *
1276 1276
      * @return string
1277 1277
      */
1278
-    protected function getWhereStrIfIsArray(array $where, $type = '', $andOr = 'AND', $escape = true){
1278
+    protected function getWhereStrIfIsArray(array $where, $type = '', $andOr = 'AND', $escape = true) {
1279 1279
         $_where = array();
1280
-        foreach ($where as $column => $data){
1281
-          if (is_null($data)){
1280
+        foreach ($where as $column => $data) {
1281
+          if (is_null($data)) {
1282 1282
             $data = '';
1283 1283
           }
1284 1284
           $_where[] = $type . $column . ' = ' . ($this->escape($data, $escape));
1285 1285
         }
1286
-        $where = implode(' '.$andOr.' ', $_where);
1286
+        $where = implode(' ' . $andOr . ' ', $_where);
1287 1287
         return $where;
1288 1288
     }
1289 1289
 
@@ -1293,12 +1293,12 @@  discard block
 block discarded – undo
1293 1293
      *
1294 1294
      * @return string
1295 1295
      */
1296
-    protected function getWhereStrIfOperatorIsArray($where, array $op, $type = '', $escape = true){
1296
+    protected function getWhereStrIfOperatorIsArray($where, array $op, $type = '', $escape = true) {
1297 1297
        $x = explode('?', $where);
1298 1298
        $w = '';
1299
-        foreach($x as $k => $v){
1300
-          if (! empty($v)){
1301
-              if (isset($op[$k]) && is_null($op[$k])){
1299
+        foreach ($x as $k => $v) {
1300
+          if (!empty($v)) {
1301
+              if (isset($op[$k]) && is_null($op[$k])) {
1302 1302
                 $op[$k] = '';
1303 1303
               }
1304 1304
               $w .= $type . $v . (isset($op[$k]) ? ($this->escape($op[$k], $escape)) : '');
@@ -1313,16 +1313,16 @@  discard block
 block discarded – undo
1313 1313
      *
1314 1314
      * @return string
1315 1315
      */
1316
-    protected function getWhereStrForOperator($where, $op = null, $val = null, $type = '', $escape = true){
1316
+    protected function getWhereStrForOperator($where, $op = null, $val = null, $type = '', $escape = true) {
1317 1317
        $w = '';
1318
-       if (! in_array((string)$op, $this->operatorList)){
1319
-          if (is_null($op)){
1318
+       if (!in_array((string) $op, $this->operatorList)) {
1319
+          if (is_null($op)) {
1320 1320
             $op = '';
1321 1321
           }
1322 1322
           $w = $type . $where . ' = ' . ($this->escape($op, $escape));
1323 1323
         }
1324
-        else{
1325
-          if (is_null($val)){
1324
+        else {
1325
+          if (is_null($val)) {
1326 1326
             $val = '';
1327 1327
           }
1328 1328
           $w = $type . $where . $op . ($this->escape($val, $escape));
@@ -1335,16 +1335,16 @@  discard block
 block discarded – undo
1335 1335
        * @param string $whereStr the WHERE clause string
1336 1336
        * @param  string  $andOr the separator type used 'AND', 'OR', etc.
1337 1337
        */
1338
-      protected function setWhereStr($whereStr, $andOr = 'AND'){
1339
-        if (empty($this->where)){
1338
+      protected function setWhereStr($whereStr, $andOr = 'AND') {
1339
+        if (empty($this->where)) {
1340 1340
           $this->where = $whereStr;
1341 1341
         }
1342
-        else{
1343
-          if (substr($this->where, -1) == '('){
1342
+        else {
1343
+          if (substr($this->where, -1) == '(') {
1344 1344
             $this->where = $this->where . ' ' . $whereStr;
1345 1345
           }
1346
-          else{
1347
-            $this->where = $this->where . ' '.$andOr.' ' . $whereStr;
1346
+          else {
1347
+            $this->where = $this->where . ' ' . $andOr . ' ' . $whereStr;
1348 1348
           }
1349 1349
         }
1350 1350
       }
@@ -1355,12 +1355,12 @@  discard block
 block discarded – undo
1355 1355
      *
1356 1356
      * @return string
1357 1357
      */
1358
-    protected function transformPreparedQuery($query, $data){
1359
-      if (is_array($data)){
1358
+    protected function transformPreparedQuery($query, $data) {
1359
+      if (is_array($data)) {
1360 1360
         $x = explode('?', $query);
1361 1361
         $q = '';
1362
-        foreach($x as $k => $v){
1363
-          if (! empty($v)){
1362
+        foreach ($x as $k => $v) {
1363
+          if (!empty($v)) {
1364 1364
             $q .= $v . (isset($data[$k]) ? $this->escape($data[$k]) : '');
1365 1365
           }
1366 1366
         }
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
      * 
1376 1376
      *  @return string
1377 1377
      */
1378
-    protected function getCacheBenchmarkKeyForQuery($query, $all, $array){
1379
-      if (is_array($all)){
1378
+    protected function getCacheBenchmarkKeyForQuery($query, $all, $array) {
1379
+      if (is_array($all)) {
1380 1380
         $all = 'array';
1381 1381
       }
1382 1382
       return md5($query . $all . $array);
@@ -1388,9 +1388,9 @@  discard block
 block discarded – undo
1388 1388
      *      
1389 1389
      * @return mixed
1390 1390
      */
1391
-    protected function getCacheContentForQuery($query, $all, $array){
1391
+    protected function getCacheContentForQuery($query, $all, $array) {
1392 1392
         $cacheKey = $this->getCacheBenchmarkKeyForQuery($query, $all, $array);
1393
-        if (is_object($this->cacheInstance)){
1393
+        if (is_object($this->cacheInstance)) {
1394 1394
           return $this->cacheInstance->get($cacheKey);
1395 1395
         }
1396 1396
         $instance = & get_instance()->cache;
@@ -1406,9 +1406,9 @@  discard block
 block discarded – undo
1406 1406
      * @param boolean $status whether can save the query result into cache
1407 1407
      * @param int $expire the cache TTL
1408 1408
      */
1409
-     protected function setCacheContentForQuery($query, $key, $result, $status, $expire){
1410
-        if ($status){
1411
-            $this->logger->info('Save the result for query [' .$query. '] into cache for future use');
1409
+     protected function setCacheContentForQuery($query, $key, $result, $status, $expire) {
1410
+        if ($status) {
1411
+            $this->logger->info('Save the result for query [' . $query . '] into cache for future use');
1412 1412
             $this->getCacheInstance()->set($key, $result, $expire);
1413 1413
         }
1414 1414
      }
@@ -1417,19 +1417,19 @@  discard block
 block discarded – undo
1417 1417
      * Set the result for SELECT query using PDOStatment
1418 1418
      * @see Database::query
1419 1419
      */
1420
-    protected function setQueryResultForSelect($pdoStatment, $all, $array){
1420
+    protected function setQueryResultForSelect($pdoStatment, $all, $array) {
1421 1421
       //if need return all result like list of record
1422
-      if (is_bool($all) && $all){
1422
+      if (is_bool($all) && $all) {
1423 1423
           $this->result = ($array === false) ? $pdoStatment->fetchAll(PDO::FETCH_OBJ) : $pdoStatment->fetchAll(PDO::FETCH_ASSOC);
1424 1424
       }
1425
-      else{
1425
+      else {
1426 1426
           $this->result = ($array === false) ? $pdoStatment->fetch(PDO::FETCH_OBJ) : $pdoStatment->fetch(PDO::FETCH_ASSOC);
1427 1427
       }
1428 1428
       //Sqlite and pgsql always return 0 when using rowCount()
1429
-      if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1429
+      if (in_array($this->config['driver'], array('sqlite', 'pgsql'))) {
1430 1430
         $this->numRows = count($this->result);  
1431 1431
       }
1432
-      else{
1432
+      else {
1433 1433
         $this->numRows = $pdoStatment->rowCount(); 
1434 1434
       }
1435 1435
     }
@@ -1438,13 +1438,13 @@  discard block
 block discarded – undo
1438 1438
      * Set the result for other command than SELECT query using PDOStatment
1439 1439
      * @see Database::query
1440 1440
      */
1441
-    protected function setQueryResultForNonSelect($pdoStatment){
1441
+    protected function setQueryResultForNonSelect($pdoStatment) {
1442 1442
       //Sqlite and pgsql always return 0 when using rowCount()
1443
-      if (in_array($this->config['driver'], array('sqlite', 'pgsql'))){
1443
+      if (in_array($this->config['driver'], array('sqlite', 'pgsql'))) {
1444 1444
         $this->result = 1; //to test the result for the query like UPDATE, INSERT, DELETE
1445 1445
         $this->numRows = 1;  
1446 1446
       }
1447
-      else{
1447
+      else {
1448 1448
           $this->result = $pdoStatment->rowCount() >= 0; //to test the result for the query like UPDATE, INSERT, DELETE
1449 1449
           $this->numRows = $pdoStatment->rowCount(); 
1450 1450
       }
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
     /**
1454 1454
      * Set error for database query execution
1455 1455
      */
1456
-    protected function setQueryError(){
1456
+    protected function setQueryError() {
1457 1457
       $error = $this->pdo->errorInfo();
1458 1458
       $this->error = isset($error[2]) ? $error[2] : '';
1459 1459
       $this->logger->error('The database query execution got error: ' . stringfy_vars($error));
@@ -1466,16 +1466,16 @@  discard block
 block discarded – undo
1466 1466
      * 
1467 1467
      * @return object|void
1468 1468
      */
1469
-    protected function runSqlQuery($query, $all, $array){
1469
+    protected function runSqlQuery($query, $all, $array) {
1470 1470
        //for database query execution time
1471 1471
         $benchmarkMarkerKey = $this->getCacheBenchmarkKeyForQuery($query, $all, $array);
1472 1472
         $benchmarkInstance = $this->getBenchmark();
1473
-        if (! is_object($benchmarkInstance)){
1473
+        if (!is_object($benchmarkInstance)) {
1474 1474
           $obj = & get_instance();
1475 1475
           $benchmarkInstance = $obj->benchmark; 
1476 1476
           $this->setBenchmark($benchmarkInstance);
1477 1477
         }
1478
-        if (! $this->pdo){
1478
+        if (!$this->pdo) {
1479 1479
             $this->connect();
1480 1480
         }
1481 1481
         
@@ -1486,10 +1486,10 @@  discard block
 block discarded – undo
1486 1486
         //get response time for this query
1487 1487
         $responseTime = $benchmarkInstance->elapsedTime('DATABASE_QUERY_START(' . $benchmarkMarkerKey . ')', 'DATABASE_QUERY_END(' . $benchmarkMarkerKey . ')');
1488 1488
         //TODO use the configuration value for the high response time currently is 1 second
1489
-        if ($responseTime >= 1 ){
1490
-            $this->logger->warning('High response time while processing database query [' .$query. ']. The response time is [' .$responseTime. '] sec.');
1489
+        if ($responseTime >= 1) {
1490
+            $this->logger->warning('High response time while processing database query [' . $query . ']. The response time is [' . $responseTime . '] sec.');
1491 1491
         }
1492
-        if ($sqlQuery){
1492
+        if ($sqlQuery) {
1493 1493
           return $sqlQuery;
1494 1494
         }
1495 1495
         $this->setQueryError();
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
     /**
1499 1499
      * Reset the database class attributs to the initail values before each query.
1500 1500
      */
1501
-    private function reset(){
1501
+    private function reset() {
1502 1502
       $this->select   = '*';
1503 1503
       $this->from     = null;
1504 1504
       $this->where    = null;
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
     /**
1519 1519
      * The class destructor
1520 1520
      */
1521
-    public function __destruct(){
1521
+    public function __destruct() {
1522 1522
       $this->pdo = null;
1523 1523
   }
1524 1524
 
Please login to merge, or discard this patch.
core/classes/Module.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
     */
26 26
    
27
-	class Module{
27
+	class Module {
28 28
 		
29 29
 		/**
30 30
 		 * list of loaded module
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(self::$logger == null){
47
-				self::$logger[0] =& class_loader('Log', 'classes');
45
+		private static function getLogger() {
46
+			if (self::$logger == null) {
47
+				self::$logger[0] = & class_loader('Log', 'classes');
48 48
 				self::$logger[0]->setLogger('Library::Module');
49 49
 			}
50 50
 			return self::$logger[0];
@@ -53,27 +53,27 @@  discard block
 block discarded – undo
53 53
 		/**
54 54
 		 * Initialise the module list by scanning the directory MODULE_PATH
55 55
 		 */
56
-		public function init(){
56
+		public function init() {
57 57
 			$logger = self::getLogger();
58 58
 			$logger->debug('Check if the application contains the modules ...');
59 59
 			$moduleDir = opendir(MODULE_PATH);
60
-			if(is_resource($moduleDir)){
61
-				while(($module = readdir($moduleDir)) !== false){
62
-					if($module != '.' && $module != '..'  && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
60
+			if (is_resource($moduleDir)) {
61
+				while (($module = readdir($moduleDir)) !== false) {
62
+					if ($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) {
63 63
 						self::$list[] = $module;
64 64
 					}
65
-					else{
66
-						$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
65
+					else {
66
+						$logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name');
67 67
 					}
68 68
 				}
69 69
 				closedir($moduleDir);
70 70
 			}
71 71
 			ksort(self::$list);
72 72
 			
73
-			if(self::hasModule()){
73
+			if (self::hasModule()) {
74 74
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
75 75
 			}
76
-			else{
76
+			else {
77 77
 				$logger->info('The application contains no module skipping');
78 78
 			}
79 79
 		}
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 		 * Get the list of the custom autoload configuration from module if exists
83 83
 		 * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values
84 84
 		 */
85
-		public static function getModulesAutoloadConfig(){
85
+		public static function getModulesAutoloadConfig() {
86 86
 			$logger = self::getLogger();
87
-			if(! self::hasModule()){
87
+			if (!self::hasModule()) {
88 88
 				$logger->info('No module was loaded skipping.');
89 89
 				return false;
90 90
 			}
@@ -97,27 +97,27 @@  discard block
 block discarded – undo
97 97
 			
98 98
 			foreach (self::$list as $module) {
99 99
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php';
100
-				if(file_exists($file)){
100
+				if (file_exists($file)) {
101 101
 					require_once $file;
102
-					if(! empty($autoload) && is_array($autoload)){
102
+					if (!empty($autoload) && is_array($autoload)) {
103 103
 						//libraries autoload
104
-						if(! empty($autoload['libraries']) && is_array($autoload['libraries'])){
104
+						if (!empty($autoload['libraries']) && is_array($autoload['libraries'])) {
105 105
 							$autoloads['libraries'] = array_merge($autoloads['libraries'], $autoload['libraries']);
106 106
 						}
107 107
 						//config autoload
108
-						if(! empty($autoload['config']) && is_array($autoload['config'])){
108
+						if (!empty($autoload['config']) && is_array($autoload['config'])) {
109 109
 							$autoloads['config'] = array_merge($autoloads['config'], $autoload['config']);
110 110
 						}
111 111
 						//models autoload
112
-						if(! empty($autoload['models']) && is_array($autoload['models'])){
112
+						if (!empty($autoload['models']) && is_array($autoload['models'])) {
113 113
 							$autoloads['models'] = array_merge($autoloads['models'], $autoload['models']);
114 114
 						}
115 115
 						//functions autoload
116
-						if(! empty($autoload['functions']) && is_array($autoload['functions'])){
116
+						if (!empty($autoload['functions']) && is_array($autoload['functions'])) {
117 117
 							$autoloads['functions'] = array_merge($autoloads['functions'], $autoload['functions']);
118 118
 						}
119 119
 						//languages autoload
120
-						if(! empty($autoload['languages']) && is_array($autoload['languages'])){
120
+						if (!empty($autoload['languages']) && is_array($autoload['languages'])) {
121 121
 							$autoloads['languages'] = array_merge($autoloads['languages'], $autoload['languages']);
122 122
 						}
123 123
 						unset($autoload);
@@ -131,23 +131,23 @@  discard block
 block discarded – undo
131 131
 		 * Get the list of the custom routes configuration from module if exists
132 132
 		 * @return array|boolean the routes list or false if no module contains the routes configuration
133 133
 		 */
134
-		public static function getModulesRoutes(){
134
+		public static function getModulesRoutes() {
135 135
 			$logger = self::getLogger();
136
-			if(! self::hasModule()){
136
+			if (!self::hasModule()) {
137 137
 				$logger->info('No module was loaded skipping.');
138 138
 				return false;
139 139
 			}
140 140
 			$routes = array();
141 141
 			foreach (self::$list as $module) {
142 142
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php';
143
-				if(file_exists($file)){
143
+				if (file_exists($file)) {
144 144
 					require_once $file;
145
-					if(! empty($route) && is_array($route)){
145
+					if (!empty($route) && is_array($route)) {
146 146
 						$routes = array_merge($routes, $route);
147 147
 						unset($route);
148 148
 					}
149
-					else{
150
-						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
149
+					else {
150
+						show_error('No routing configuration found in [' . $file . '] for module [' . $module . ']');
151 151
 					}
152 152
 				}
153 153
 			}
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
 		 * @param  string $module  the module name
162 162
 		 * @return boolean|string  false or null if no module have this controller, path the full path of the controller
163 163
 		 */
164
-		public static function findControllerFullPath($class, $module = null){
164
+		public static function findControllerFullPath($class, $module = null) {
165 165
 			$logger = self::getLogger();
166
-			if(! self::hasModule()){
166
+			if (!self::hasModule()) {
167 167
 				$logger->info('No module was loaded skiping.');
168 168
 				return false;
169 169
 			}
170 170
 			$class = str_ireplace('.php', '', $class);
171 171
 			$class = ucfirst($class);
172
-			$classFile = $class.'.php';
173
-			$logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...');
172
+			$classFile = $class . '.php';
173
+			$logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...');
174 174
 			$filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile;
175
-			if(file_exists($filePath)){
176
-				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
175
+			if (file_exists($filePath)) {
176
+				$logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
177 177
 				return $filePath;
178 178
 			}
179
-			else{
180
-				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
179
+			else {
180
+				$logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']');
181 181
 				return false;
182 182
 			}
183 183
 		}
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 		 * @param string $module the module name
189 189
 		 * @return boolean|string  false or null if no module have this model, return the full path of this model
190 190
 		 */
191
-		public static function findModelFullPath($class, $module = null){
191
+		public static function findModelFullPath($class, $module = null) {
192 192
 			$logger = self::getLogger();
193
-			if(! self::hasModule()){
193
+			if (!self::hasModule()) {
194 194
 				$logger->info('No module was loaded skiping.');
195 195
 				return false;
196 196
 			}
197 197
 			$class = str_ireplace('.php', '', $class);
198 198
 			$class = ucfirst($class);
199
-			$classFile = $class.'.php';
200
-			$logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...');
199
+			$classFile = $class . '.php';
200
+			$logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...');
201 201
 			$filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile;
202
-			if(file_exists($filePath)){
203
-				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
202
+			if (file_exists($filePath)) {
203
+				$logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
204 204
 				return $filePath;
205 205
 			}
206
-			else{
207
-				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
206
+			else {
207
+				$logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']');
208 208
 				return false;
209 209
 			}
210 210
 		}
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 		 * @param string $module the module name
216 216
 		 * @return boolean|string  false or null if no module have this configuration,  return the full path of this configuration
217 217
 		 */
218
-		public static function findConfigFullPath($configuration, $module = null){
218
+		public static function findConfigFullPath($configuration, $module = null) {
219 219
 			$logger = self::getLogger();
220
-			if(! self::hasModule()){
220
+			if (!self::hasModule()) {
221 221
 				$logger->info('No module was loaded skiping.');
222 222
 				return false;
223 223
 			}
224 224
 			$configuration = str_ireplace('.php', '', $configuration);
225
-			$file = $configuration.'.php';
226
-			$logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...');
225
+			$file = $configuration . '.php';
226
+			$logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...');
227 227
 			$filePath = MODULE_PATH . $module . DS . 'config' . DS . $file;
228
-			if(file_exists($filePath)){
229
-				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
228
+			if (file_exists($filePath)) {
229
+				$logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']');
230 230
 				return $filePath;
231 231
 			}
232
-			else{
233
-				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
232
+			else {
233
+				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']');
234 234
 				return false;
235 235
 			}
236 236
 		}
@@ -241,23 +241,23 @@  discard block
 block discarded – undo
241 241
 		 * @param string $module the module name
242 242
 		 * @return boolean|string  false or null if no module have this helper,  return the full path of this helper
243 243
 		 */
244
-		public static function findFunctionFullPath($helper, $module = null){
244
+		public static function findFunctionFullPath($helper, $module = null) {
245 245
 			$logger = self::getLogger();
246
-			if(! self::hasModule()){
246
+			if (!self::hasModule()) {
247 247
 				$logger->info('No module was loaded skiping.');
248 248
 				return false;
249 249
 			}
250 250
 			$helper = str_ireplace('.php', '', $helper);
251 251
 			$helper = str_ireplace('function_', '', $helper);
252
-			$file = 'function_'.$helper.'.php';
253
-			$logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...');
252
+			$file = 'function_' . $helper . '.php';
253
+			$logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...');
254 254
 			$filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file;
255
-			if(file_exists($filePath)){
256
-				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
255
+			if (file_exists($filePath)) {
256
+				$logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']');
257 257
 				return $filePath;
258 258
 			}
259
-			else{
260
-				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
259
+			else {
260
+				$logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']');
261 261
 				return false;
262 262
 			}
263 263
 		}
@@ -269,22 +269,22 @@  discard block
 block discarded – undo
269 269
 		 * @param string $module the module name
270 270
 		 * @return boolean|string  false or null if no module have this library,  return the full path of this library
271 271
 		 */
272
-		public static function findLibraryFullPath($class, $module = null){
272
+		public static function findLibraryFullPath($class, $module = null) {
273 273
 			$logger = self::getLogger();
274
-			if(! self::hasModule()){
274
+			if (!self::hasModule()) {
275 275
 				$logger->info('No module was loaded skiping.');
276 276
 				return false;
277 277
 			}
278 278
 			$class = str_ireplace('.php', '', $class);
279
-			$file = $class.'.php';
280
-			$logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...');
279
+			$file = $class . '.php';
280
+			$logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...');
281 281
 			$filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file;
282
-			if(file_exists($filePath)){
283
-				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
282
+			if (file_exists($filePath)) {
283
+				$logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
284 284
 				return $filePath;
285 285
 			}
286
-			else{
287
-				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
286
+			else {
287
+				$logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']');
288 288
 				return false;
289 289
 			}
290 290
 		}
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 		 * @param string $module the module name to check
297 297
 		 * @return boolean|string  false or null if no module have this view, path the full path of the view
298 298
 		 */
299
-		public static function findViewFullPath($view, $module = null){
299
+		public static function findViewFullPath($view, $module = null) {
300 300
 			$logger = self::getLogger();
301
-			if(! self::hasModule()){
301
+			if (!self::hasModule()) {
302 302
 				$logger->info('No module was loaded skiping.');
303 303
 				return false;
304 304
 			}
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
 			$view = trim($view, '/\\');
307 307
 			$view = str_ireplace('/', DS, $view);
308 308
 			$viewFile = $view . '.php';
309
-			$logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...');
309
+			$logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...');
310 310
 			$filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile;
311
-			if(file_exists($filePath)){
312
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
311
+			if (file_exists($filePath)) {
312
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']');
313 313
 				return $filePath;
314 314
 			}
315
-			else{
316
-				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
315
+			else {
316
+				$logger->info('View [' . $view . '] does not exist in the module [' . $module . ']');
317 317
 				return false;
318 318
 			}
319 319
 		}
@@ -325,23 +325,23 @@  discard block
 block discarded – undo
325 325
 		 * @param string $appLang the application language like 'en', 'fr'
326 326
 		 * @return boolean|string  false or null if no module have this language,  return the full path of this language
327 327
 		 */
328
-		public static function findLanguageFullPath($language, $module = null, $appLang){
328
+		public static function findLanguageFullPath($language, $module = null, $appLang) {
329 329
 			$logger = self::getLogger();
330
-			if(! self::hasModule()){
330
+			if (!self::hasModule()) {
331 331
 				$logger->info('No module was loaded skiping.');
332 332
 				return false;
333 333
 			}
334 334
 			$language = str_ireplace('.php', '', $language);
335 335
 			$language = str_ireplace('lang_', '', $language);
336
-			$file = 'lang_'.$language.'.php';
337
-			$logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...');
336
+			$file = 'lang_' . $language . '.php';
337
+			$logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...');
338 338
 			$filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file;
339
-			if(file_exists($filePath)){
340
-				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
339
+			if (file_exists($filePath)) {
340
+				$logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']');
341 341
 				return $filePath;
342 342
 			}
343
-			else{
344
-				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
343
+			else {
344
+				$logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']');
345 345
 				return false;
346 346
 			}
347 347
 		}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 		 * Get the list of module loaded
351 351
 		 * @return array the module list
352 352
 		 */
353
-		public static function getModuleList(){
353
+		public static function getModuleList() {
354 354
 			return self::$list;
355 355
 		}
356 356
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		 * Check if the application has an module
359 359
 		 * @return boolean
360 360
 		 */
361
-		public static function hasModule(){
361
+		public static function hasModule() {
362 362
 			return !empty(self::$list);
363 363
 		}
364 364
 
Please login to merge, or discard this patch.