| Conditions | 9 |
| Paths | 32 |
| Total Lines | 63 |
| 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 |
||
| 146 | public function run() |
||
| 147 | { |
||
| 148 | $jaxon = jaxon(); |
||
| 149 | $di = $jaxon->di(); |
||
| 150 | $app = $jaxon->app(); |
||
|
|
|||
| 151 | $view = $di->getViewManager(); |
||
| 152 | |||
| 153 | // Event before setting up the module |
||
| 154 | $this->triggerEvent('pre.setup'); |
||
| 155 | |||
| 156 | // Add the view renderer |
||
| 157 | $view->addRenderer('jaxon', function () { |
||
| 158 | return new View\View(); |
||
| 159 | }); |
||
| 160 | |||
| 161 | // Set the pagination view namespace |
||
| 162 | $view->addNamespace('pagination', '', '', 'jaxon'); |
||
| 163 | |||
| 164 | // Set the the view facade as template renderer |
||
| 165 | $di->alias(TemplateRenderer::class, ViewRenderer::class); |
||
| 166 | // Setup the lib config options. |
||
| 167 | $di->getConfig()->setOptions($this->aLibOptions); |
||
| 168 | |||
| 169 | // Event before the module has set the config |
||
| 170 | $this->triggerEvent('pre.config'); |
||
| 171 | |||
| 172 | // Get the app config options. |
||
| 173 | $xAppConfig = $di->newConfig($this->aAppOptions); |
||
| 174 | $xAppConfig->setOption('options.views.default', 'default'); |
||
| 175 | // Setup the app. |
||
| 176 | $this->setupApp($xAppConfig); |
||
| 177 | |||
| 178 | // Event after the module has read the config |
||
| 179 | $this->triggerEvent('post.config'); |
||
| 180 | |||
| 181 | // Use the Composer autoloader. It's important to call this before triggers and callbacks. |
||
| 182 | // $jaxon->useComposerAutoloader(); |
||
| 183 | // Jaxon library settings |
||
| 184 | if(!$jaxon->hasOption('js.app.export')) |
||
| 185 | { |
||
| 186 | $jaxon->setOption('js.app.export', $this->bExportJs); |
||
| 187 | } |
||
| 188 | if(!$jaxon->hasOption('js.app.minify')) |
||
| 189 | { |
||
| 190 | $jaxon->setOption('js.app.minify', $this->bMinifyJs); |
||
| 191 | } |
||
| 192 | if(!$jaxon->hasOption('js.app.uri') && $this->sJsUri != '') |
||
| 193 | { |
||
| 194 | $jaxon->setOption('js.app.uri', $this->sJsUri); |
||
| 195 | } |
||
| 196 | if(!$jaxon->hasOption('js.app.dir') && $this->sJsDir != '') |
||
| 197 | { |
||
| 198 | $jaxon->setOption('js.app.dir', $this->sJsDir); |
||
| 199 | } |
||
| 200 | // Set the request URI |
||
| 201 | if(!$jaxon->hasOption('core.request.uri') && $this->sUri != '') |
||
| 202 | { |
||
| 203 | $jaxon->setOption('core.request.uri', $this->sUri); |
||
| 204 | } |
||
| 205 | |||
| 206 | // Event after setting up the module |
||
| 207 | $this->triggerEvent('post.setup'); |
||
| 208 | } |
||
| 209 | } |
||
| 210 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.