| Conditions | 7 |
| Paths | 12 |
| Total Lines | 56 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 70 | public function __construct($init_parameters) |
||
| 71 | { |
||
| 72 | $this->prepare(); |
||
| 73 | |||
| 74 | $this->devMode = $init_parameters["environment"]["dev_mode"]; |
||
| 75 | $this->modules = $init_parameters["modules"]; |
||
| 76 | |||
| 77 | /* |
||
| 78 | * DEV MODE: |
||
| 79 | * Set Development or production environment |
||
| 80 | */ |
||
| 81 | |||
| 82 | if ($this->devMode) |
||
| 83 | { |
||
| 84 | ini_set('display_errors', 1); |
||
| 85 | |||
| 86 | // See errors |
||
| 87 | // error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); |
||
| 88 | |||
| 89 | // PHP 5.4 |
||
| 90 | // error_reporting(E_ALL); |
||
| 91 | |||
| 92 | // Best way to view all possible errors |
||
| 93 | error_reporting(-1); |
||
| 94 | } |
||
| 95 | else { |
||
| 96 | ini_set('display_errors', 0); |
||
| 97 | error_reporting(-1); |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->loadModules($this->modules); |
||
| 101 | |||
| 102 | $this->router = new Router($init_parameters["router"]["routes"]); |
||
| 103 | $this->router->setBasePath($init_parameters["environment"]["base_path"]); |
||
| 104 | |||
| 105 | # load routes from application.config.php |
||
| 106 | if (file_exists("config/application.config.php")) |
||
| 107 | { |
||
| 108 | $app_config_file = require "config/application.config.php"; |
||
| 109 | |||
| 110 | foreach ($app_config_file["router"]["routes"] as $name => $route) |
||
| 111 | { |
||
| 112 | if ($route instanceof \Zend\Router\Http\RouteInterface) |
||
| 113 | $this->getRouter()->addZendRoute($name, $route); |
||
| 114 | else |
||
| 115 | $this->getRouter()->addRoute($route); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | |||
| 119 | # load routes from modules |
||
| 120 | foreach ($this->modules as $module) |
||
| 121 | { |
||
| 122 | if (file_exists("module/$module/config/module.config.php")) |
||
| 123 | { |
||
| 124 | $module_config_file = require "module/$module/config/module.config.php"; |
||
| 125 | $this->getRouter()->addRoute($module_config_file["router"]["routes"]); |
||
| 126 | } |
||
| 200 | } |