@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | if ($init) { |
47 | 47 | $this->init(); |
48 | 48 | //@codeCoverageIgnoreStart |
49 | - if (ENVIRONMENT == 'production' && in_array(strtolower($this->config['log_level']), array('debug', 'info', 'notice'))) { |
|
49 | + if (ENVIRONMENT == 'production' && in_array(strtolower($this->config['log_level']), array('debug', 'info', 'notice'))) { |
|
50 | 50 | $this->logger->warning('You are in production environment, please set ' |
51 | - . 'log level to WARNING, ERROR, CRITICAL, ALERT, EMERGENCY to increase the application performance'); |
|
51 | + . 'log level to WARNING, ERROR, CRITICAL, ALERT, EMERGENCY to increase the application performance'); |
|
52 | 52 | } |
53 | 53 | //@codeCoverageIgnoreEnd |
54 | 54 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | if (empty($this->config['base_url'])) { |
147 | 147 | if (ENVIRONMENT == 'production') { |
148 | 148 | $this->logger->warning('Application base URL is not set or invalid, please' |
149 | - . ' set application base URL to increase the application loading time'); |
|
149 | + . ' set application base URL to increase the application loading time'); |
|
150 | 150 | } |
151 | 151 | $baseUrl = null; |
152 | 152 | $protocol = 'http'; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ); |
174 | 174 | } else { |
175 | 175 | $this->logger->warning('Can not determine the application ' |
176 | - . 'base URL automatically, use http://localhost as default'); |
|
176 | + . 'base URL automatically, use http://localhost as default'); |
|
177 | 177 | $baseUrl = 'http://localhost/'; |
178 | 178 | } |
179 | 179 | $this->config['base_url'] = $baseUrl; |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Return the server port using variable |
|
186 | - * |
|
187 | - * @codeCoverageIgnore |
|
188 | - * @return string |
|
189 | - */ |
|
185 | + * Return the server port using variable |
|
186 | + * |
|
187 | + * @codeCoverageIgnore |
|
188 | + * @return string |
|
189 | + */ |
|
190 | 190 | protected function getServerPort() { |
191 | 191 | $globals = & class_loader('GlobalVar', 'classes'); |
192 | 192 | $serverPort = $globals->server('SERVER_PORT'); |
@@ -318,7 +318,7 @@ |
||
318 | 318 | * Get some parameters need like ip address, hostname, browser info, etc. |
319 | 319 | * @return array |
320 | 320 | */ |
321 | - protected function getSessionDataParams(){ |
|
321 | + protected function getSessionDataParams() { |
|
322 | 322 | $this->OBJ->loader->functions('user_agent'); |
323 | 323 | $this->OBJ->loader->library('Browser'); |
324 | 324 |
@@ -276,14 +276,14 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | - * Setting the route configuration using the configuration file |
|
280 | - * and additional configuration from param |
|
281 | - * @param array $overwriteConfig the additional configuration |
|
282 | - * to overwrite with the existing one |
|
283 | - * @param boolean $useConfigFile whether to use route configuration file |
|
284 | - * |
|
285 | - * @return object |
|
286 | - */ |
|
279 | + * Setting the route configuration using the configuration file |
|
280 | + * and additional configuration from param |
|
281 | + * @param array $overwriteConfig the additional configuration |
|
282 | + * to overwrite with the existing one |
|
283 | + * @param boolean $useConfigFile whether to use route configuration file |
|
284 | + * |
|
285 | + * @return object |
|
286 | + */ |
|
287 | 287 | public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true) { |
288 | 288 | $route = array(); |
289 | 289 | if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')) { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | //the URL like http://domain.com/module/controller/method/arg1/arg2/argn |
365 | 365 | if (!$this->controller) { |
366 | 366 | $this->logger->info('Cannot determine the routing information ' |
367 | - . 'using the predefined routes configuration, will use the request URI parameters'); |
|
367 | + . 'using the predefined routes configuration, will use the request URI parameters'); |
|
368 | 368 | //determine route parameters using the route URI param |
369 | 369 | $this->determineRouteParamsFromRequestUri(); |
370 | 370 | } |
@@ -478,11 +478,11 @@ discard block |
||
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
481 | - /** |
|
482 | - * Remove the URL suffix and query string values if exists |
|
483 | - * @param string $uri the route URI to process |
|
484 | - * @return string the final route uri after processed |
|
485 | - */ |
|
481 | + /** |
|
482 | + * Remove the URL suffix and query string values if exists |
|
483 | + * @param string $uri the route URI to process |
|
484 | + * @return string the final route uri after processed |
|
485 | + */ |
|
486 | 486 | protected function removeSuffixAndQueryStringFromUri($uri) { |
487 | 487 | $this->logger->debug('Check if URL suffix is enabled in the configuration'); |
488 | 488 | //remove url suffix from the request URI |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | $this->logger->info( |
599 | 599 | 'After loop in predefined routes configuration,' |
600 | 600 | . 'the module name is set but the controller is not set,' |
601 | - . 'so we will use module as the controller' |
|
601 | + . 'so we will use module as the controller' |
|
602 | 602 | ); |
603 | 603 | $this->controller = $this->module; |
604 | 604 | } |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * Remove the DOCUMENT_ROOT and front controller from segments if exists |
451 | 451 | * @return void |
452 | 452 | */ |
453 | - protected function removeDocumentRootFrontControllerFromSegments(){ |
|
453 | + protected function removeDocumentRootFrontControllerFromSegments() { |
|
454 | 454 | $segment = $this->segments; |
455 | 455 | $globals = & class_loader('GlobalVar', 'classes'); |
456 | 456 | $rootFolder = substr($globals->server('SCRIPT_NAME'), 0, strpos( |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | break; |
582 | 582 | } |
583 | 583 | } |
584 | - if($findIndex !== -1){ |
|
584 | + if ($findIndex !== -1) { |
|
585 | 585 | /* |
586 | 586 | * $args[0] => full string captured by preg_match |
587 | 587 | * $args[1], $args[2], $args[n] => contains the value of |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * Find file path of the current controller using the current module |
609 | 609 | * @return boolean true if the file path is found otherwise false. |
610 | 610 | */ |
611 | - protected function findControllerFullPathUsingCurrentModule(){ |
|
611 | + protected function findControllerFullPathUsingCurrentModule() { |
|
612 | 612 | $path = $this->moduleInstance->findControllerFullPath(ucfirst($this->controller), $this->module); |
613 | 613 | if (!$path) { |
614 | 614 | $this->logger->info('The controller [' . $this->controller . '] not ' |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * or the current request does not use module |
626 | 626 | * @return void |
627 | 627 | */ |
628 | - protected function setRouteParamsIfNoModuleOrNotFound(){ |
|
628 | + protected function setRouteParamsIfNoModuleOrNotFound() { |
|
629 | 629 | $segment = $this->segments; |
630 | 630 | //controller |
631 | 631 | if (isset($segment[0])) { |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * or the current request use module |
647 | 647 | * @return void |
648 | 648 | */ |
649 | - protected function setRouteParamsIfAppHasModuleOrFound(){ |
|
649 | + protected function setRouteParamsIfAppHasModuleOrFound() { |
|
650 | 650 | //get the module list |
651 | 651 | $modules = $this->moduleInstance->getModuleList(); |
652 | 652 | $segment = $this->segments; |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | if (isset($segment[0])) { |
659 | 659 | $this->controller = $segment[0]; |
660 | 660 | //check if the request use the same module name and controller |
661 | - if($this->findControllerFullPathUsingCurrentModule()){ |
|
661 | + if ($this->findControllerFullPathUsingCurrentModule()) { |
|
662 | 662 | array_shift($segment); |
663 | 663 | } |
664 | 664 | } |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | $this->log(self::DEBUG, $message); |
181 | 181 | } |
182 | 182 | |
183 | - /** |
|
184 | - * Logs with an arbitrary level. |
|
185 | - * |
|
186 | - * @param integer|string $level the log level in integer or string format, |
|
187 | - * if is string will convert into integer. |
|
188 | - * @param string $message the log message to be saved |
|
189 | - */ |
|
183 | + /** |
|
184 | + * Logs with an arbitrary level. |
|
185 | + * |
|
186 | + * @param integer|string $level the log level in integer or string format, |
|
187 | + * if is string will convert into integer. |
|
188 | + * @param string $message the log message to be saved |
|
189 | + */ |
|
190 | 190 | public function log($level, $message) { |
191 | 191 | $configLogLevel = get_config('log_level'); |
192 | 192 | if (!$configLogLevel) { |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | //NOTE: here need put the show_error() "logging" to false |
199 | 199 | //to prevent self function loop call |
200 | 200 | show_error('Invalid config log level [' . $configLogLevel . '], ' |
201 | - . 'the value must be one of the following: ' |
|
202 | - . implode(', ', array_map('strtoupper', self::$validConfigLevel)) |
|
203 | - , 'Log Config Error', |
|
204 | - $logging = false |
|
205 | - ); |
|
201 | + . 'the value must be one of the following: ' |
|
202 | + . implode(', ', array_map('strtoupper', self::$validConfigLevel)) |
|
203 | + , 'Log Config Error', |
|
204 | + $logging = false |
|
205 | + ); |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | protected function levelCanSaveLog($level) { |
272 | 272 | $result = true; |
273 | 273 | $configLogLevel = get_config('log_level'); |
274 | - //check if can save log regarding the log level configuration |
|
274 | + //check if can save log regarding the log level configuration |
|
275 | 275 | $configLevel = self::getLevelValue($configLogLevel); |
276 | 276 | if ($configLevel > $level) { |
277 | 277 | //can't log |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | //NOTE: here need put the show_error() "logging" to false |
352 | 352 | //to prevent self function loop call |
353 | 353 | show_error('Error : the log dir does not exist or is not writable', |
354 | - 'Log directory error', $logging = false); |
|
354 | + 'Log directory error', $logging = false); |
|
355 | 355 | } |
356 | 356 | return $logSavePath . 'logs-' . date('Y-m-d') . '.log'; |
357 | 357 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | protected function getLogDebugBacktraceInfo() { |
318 | 318 | $dtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
319 | 319 | $i = 0; |
320 | - while ($dtrace[$i]['file'] == __FILE__ ) { |
|
320 | + while ($dtrace[$i]['file'] == __FILE__) { |
|
321 | 321 | $i++; |
322 | 322 | } |
323 | 323 | $fileInfo = $dtrace[$i]; |
@@ -333,11 +333,11 @@ discard block |
||
333 | 333 | if (isset($fileInfo['line'])) { |
334 | 334 | $line = $fileInfo['line']; |
335 | 335 | } |
336 | - if (isset($dtrace[$i+1]['function'])) { |
|
337 | - $function = $dtrace[$i+1]['function']; |
|
336 | + if (isset($dtrace[$i + 1]['function'])) { |
|
337 | + $function = $dtrace[$i + 1]['function']; |
|
338 | 338 | } |
339 | - if (isset($dtrace[$i+1]['class'])) { |
|
340 | - $class = $dtrace[$i+1]['class']; |
|
339 | + if (isset($dtrace[$i + 1]['class'])) { |
|
340 | + $class = $dtrace[$i + 1]['class']; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return array( |
@@ -1,32 +1,32 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
3 | - /** |
|
4 | - * TNH Framework |
|
5 | - * |
|
6 | - * A simple PHP framework using HMVC architecture |
|
7 | - * |
|
8 | - * This content is released under the MIT License (MIT) |
|
9 | - * |
|
10 | - * Copyright (c) 2017 TNH Framework |
|
11 | - * |
|
12 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
13 | - * of this software and associated documentation files (the "Software"), to deal |
|
14 | - * in the Software without restriction, including without limitation the rights |
|
15 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
16 | - * copies of the Software, and to permit persons to whom the Software is |
|
17 | - * furnished to do so, subject to the following conditions: |
|
18 | - * |
|
19 | - * The above copyright notice and this permission notice shall be included in all |
|
20 | - * copies or substantial portions of the Software. |
|
21 | - * |
|
22 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
23 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
24 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
25 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
26 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
27 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
28 | - * SOFTWARE. |
|
29 | - */ |
|
3 | + /** |
|
4 | + * TNH Framework |
|
5 | + * |
|
6 | + * A simple PHP framework using HMVC architecture |
|
7 | + * |
|
8 | + * This content is released under the MIT License (MIT) |
|
9 | + * |
|
10 | + * Copyright (c) 2017 TNH Framework |
|
11 | + * |
|
12 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
13 | + * of this software and associated documentation files (the "Software"), to deal |
|
14 | + * in the Software without restriction, including without limitation the rights |
|
15 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
16 | + * copies of the Software, and to permit persons to whom the Software is |
|
17 | + * furnished to do so, subject to the following conditions: |
|
18 | + * |
|
19 | + * The above copyright notice and this permission notice shall be included in all |
|
20 | + * copies or substantial portions of the Software. |
|
21 | + * |
|
22 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
23 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
24 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
25 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
26 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
27 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
28 | + * SOFTWARE. |
|
29 | + */ |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @file bootstrap.php |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | . '] please install a PHP version that is compatible.', 'PHP Error environment'); |
94 | 94 | } |
95 | 95 | $LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_MIN_PHP_VERSION |
96 | - . 'REQUIRED MAXIMUM: ' . TNH_MAX_PHP_VERSION . '], application can work without any issue'); |
|
96 | + . 'REQUIRED MAXIMUM: ' . TNH_MAX_PHP_VERSION . '], application can work without any issue'); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Setting of the PHP error message handling function |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * Register controllers autoload function |
157 | 157 | */ |
158 | - spl_autoload_register('autoload_controller'); |
|
158 | + spl_autoload_register('autoload_controller'); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Loading Security class |
@@ -137,7 +137,7 @@ |
||
137 | 137 | */ |
138 | 138 | $TIMEZONE = get_config('server_timezone', 'UTC'); |
139 | 139 | if (!date_default_timezone_set($TIMEZONE)) { |
140 | - show_error('Invalid server timezone configuration "' .$TIMEZONE. '"'); |
|
140 | + show_error('Invalid server timezone configuration "' . $TIMEZONE . '"'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function add($name) { |
60 | 60 | if (in_array($name, $this->list)) { |
61 | - $this->logger->warning('The module [' .$name. '] already added skipping.'); |
|
62 | - return $this; |
|
61 | + $this->logger->warning('The module [' .$name. '] already added skipping.'); |
|
62 | + return $this; |
|
63 | 63 | } |
64 | 64 | $this->list[] = $name; |
65 | 65 | return $this; |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $this->list = array(); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Get the list of module loaded |
|
96 | - * @return array the module list |
|
97 | - */ |
|
94 | + /** |
|
95 | + * Get the list of module loaded |
|
96 | + * @return array the module list |
|
97 | + */ |
|
98 | 98 | public function getModuleList() { |
99 | 99 | return $this->list; |
100 | 100 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->logger->debug('Check if the application contains the modules ...'); |
242 | 242 | $dirList = glob(MODULE_PATH . '*', GLOB_ONLYDIR); |
243 | 243 | if ($dirList !== false) { |
244 | - $this->list = array_map('basename', $dirList); |
|
244 | + $this->list = array_map('basename', $dirList); |
|
245 | 245 | } |
246 | 246 | if (!empty($this->list)) { |
247 | 247 | $this->logger->info('The application contains the module below [' . implode(', ', $this->list) . ']'); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $filePath = MODULE_PATH . $module . DS . $type . DS . $classFile; |
265 | 265 | if (file_exists($filePath)) { |
266 | 266 | $this->logger->info('Found class [' . $class . '] in module [' . $module . '] ' |
267 | - . 'for [' . $type . '] the file path is [' . $filePath . ']'); |
|
267 | + . 'for [' . $type . '] the file path is [' . $filePath . ']'); |
|
268 | 268 | return $filePath; |
269 | 269 | } |
270 | 270 | $this->logger->info('Class [' . $class . '] does not exist in the module [' . $module . '] for [' . $type . ']'); |
@@ -58,7 +58,7 @@ |
||
58 | 58 | */ |
59 | 59 | public function add($name) { |
60 | 60 | if (in_array($name, $this->list)) { |
61 | - $this->logger->warning('The module [' .$name. '] already added skipping.'); |
|
61 | + $this->logger->warning('The module [' . $name . '] already added skipping.'); |
|
62 | 62 | return $this; |
63 | 63 | } |
64 | 64 | $this->list[] = $name; |