| Conditions | 6 |
| Paths | 10 |
| Total Lines | 77 |
| Code Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 189 | public function execute() |
||
| 190 | { |
||
| 191 | $options = input()->get(); |
||
| 192 | |||
| 193 | if (empty($options)) { |
||
| 194 | $_GET[ 'switch' ] = 'ON'; |
||
| 195 | $_GET[ 'mode' ] = 'default'; |
||
| 196 | $_GET[ 'lifetime' ] = 300; |
||
| 197 | $_GET[ 'title' ] = language()->getLine(strtoupper('CLI_MAINTENANCE_TITLE')); |
||
| 198 | $_GET[ 'message' ] = language()->getLine(strtoupper('CLI_MAINTENANCE_MESSAGE')); |
||
| 199 | } else { |
||
| 200 | $_GET[ 'mode' ] = 'default'; |
||
| 201 | $_GET[ 'lifetime' ] = 300; |
||
| 202 | $_GET[ 'title' ] = language()->getLine(strtoupper('CLI_MAINTENANCE_TITLE')); |
||
| 203 | $_GET[ 'message' ] = language()->getLine(strtoupper('CLI_MAINTENANCE_MESSAGE')); |
||
| 204 | } |
||
| 205 | |||
| 206 | $this->__callOptions(); |
||
| 207 | |||
| 208 | if ($this->optionSwitch === 'ON') { |
||
| 209 | if (cache()->hasItem('maintenance')) { |
||
| 210 | |||
| 211 | $maintenanceInfo = cache()->getItem('maintenance')->get(); |
||
| 212 | output()->write( |
||
|
|
|||
| 213 | (new Format()) |
||
| 214 | ->setContextualClass(Format::DANGER) |
||
| 215 | ->setString(language()->getLine('CLI_MAINTENANCE_ALREADY_STARTED', [ |
||
| 216 | $maintenanceInfo[ 'mode' ], |
||
| 217 | $maintenanceInfo[ 'datetime' ], |
||
| 218 | date('r', strtotime($maintenanceInfo[ 'datetime' ]) + $maintenanceInfo[ 'lifetime' ]), |
||
| 219 | $maintenanceInfo[ 'title' ], |
||
| 220 | $maintenanceInfo[ 'message' ], |
||
| 221 | ])) |
||
| 222 | ->setNewLinesAfter(1) |
||
| 223 | ); |
||
| 224 | } else { |
||
| 225 | output()->write( |
||
| 226 | (new Format()) |
||
| 227 | ->setContextualClass(Format::WARNING) |
||
| 228 | ->setString(language()->getLine('CLI_MAINTENANCE_STARTED', [ |
||
| 229 | $datetime = date('r'), |
||
| 230 | $this->optionLifetime, |
||
| 231 | $this->optionMode, |
||
| 232 | $this->optionTitle, |
||
| 233 | $this->optionMessage, |
||
| 234 | ])) |
||
| 235 | ->setNewLinesAfter(1) |
||
| 236 | ); |
||
| 237 | |||
| 238 | cache()->save(new Item('maintenance', [ |
||
| 239 | 'datetime' => $datetime, |
||
| 240 | 'lifetime' => $this->optionLifetime, |
||
| 241 | 'mode' => $this->optionMode, |
||
| 242 | 'title' => $this->optionTitle, |
||
| 243 | 'message' => $this->optionMessage, |
||
| 244 | ], $this->optionLifetime)); |
||
| 245 | } |
||
| 246 | |||
| 247 | } elseif ($this->optionSwitch === 'OFF') { |
||
| 248 | if (cache()->hasItem('maintenance')) { |
||
| 249 | output()->write( |
||
| 250 | (new Format()) |
||
| 251 | ->setContextualClass(Format::DANGER) |
||
| 252 | ->setString(language()->getLine('CLI_MAINTENANCE_STOPPED', [ |
||
| 253 | $this->optionMode, |
||
| 254 | date('r'), |
||
| 255 | ])) |
||
| 256 | ->setNewLinesAfter(1) |
||
| 257 | ); |
||
| 258 | |||
| 259 | cache()->deleteItem('maintenance'); |
||
| 260 | } else { |
||
| 261 | output()->write( |
||
| 262 | (new Format()) |
||
| 263 | ->setContextualClass(Format::DANGER) |
||
| 264 | ->setString(language()->getLine('CLI_MAINTENANCE_INACTIVE')) |
||
| 265 | ->setNewLinesAfter(1) |
||
| 266 | ); |
||
| 270 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.