| Conditions | 6 |
| Paths | 13 |
| Total Lines | 64 |
| Code Lines | 44 |
| 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 |
||
| 44 | public function execute() |
||
| 45 | { |
||
| 46 | $this->__callOptions(); |
||
| 47 | |||
| 48 | if (empty($this->optionFilename)) { |
||
| 49 | output()->write( |
||
|
|
|||
| 50 | (new Format()) |
||
| 51 | ->setContextualClass(Format::DANGER) |
||
| 52 | ->setString(language()->getLine('CLI_MAKE_CONFIG_E_FILENAME')) |
||
| 53 | ->setNewLinesAfter(1) |
||
| 54 | ); |
||
| 55 | |||
| 56 | exit(EXIT_ERROR); |
||
| 57 | } |
||
| 58 | |||
| 59 | if (strpos($this->optionPath, 'Config') === false) { |
||
| 60 | $filePath = $this->optionPath . 'Config' . DIRECTORY_SEPARATOR . $this->optionFilename; |
||
| 61 | } else { |
||
| 62 | $filePath = $this->optionPath . $this->optionFilename; |
||
| 63 | } |
||
| 64 | |||
| 65 | if ( ! is_dir(dirname($filePath))) { |
||
| 66 | mkdir(dirname($filePath), 777, true); |
||
| 67 | } |
||
| 68 | |||
| 69 | if (is_file($filePath)) { |
||
| 70 | output()->write( |
||
| 71 | (new Format()) |
||
| 72 | ->setContextualClass(Format::DANGER) |
||
| 73 | ->setString(language()->getLine('CLI_MAKE_CONFIG_E_EXISTS', [$filePath])) |
||
| 74 | ->setNewLinesAfter(1) |
||
| 75 | ); |
||
| 76 | |||
| 77 | exit(EXIT_ERROR); |
||
| 78 | } |
||
| 79 | |||
| 80 | $vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
||
| 81 | $vars[ 'CONFIG' ] = '$' . camelcase(pathinfo($filePath, PATHINFO_FILENAME)); |
||
| 82 | $vars[ 'FILEPATH' ] = $filePath; |
||
| 83 | |||
| 84 | $phpTemplate = <<<PHPTEMPLATE |
||
| 85 | <?php |
||
| 86 | /** |
||
| 87 | * Created by O2System Reactor File Generator. |
||
| 88 | * DateTime: CREATE_DATETIME |
||
| 89 | */ |
||
| 90 | |||
| 91 | // ------------------------------------------------------------------------ |
||
| 92 | |||
| 93 | CONFIG = []; |
||
| 94 | PHPTEMPLATE; |
||
| 95 | |||
| 96 | $fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate); |
||
| 97 | file_put_contents($filePath, $fileContent); |
||
| 98 | |||
| 99 | if (is_file($filePath)) { |
||
| 100 | output()->write( |
||
| 101 | (new Format()) |
||
| 102 | ->setContextualClass(Format::SUCCESS) |
||
| 103 | ->setString(language()->getLine('CLI_MAKE_CONFIG_S_MAKE', [$filePath])) |
||
| 104 | ->setNewLinesAfter(1) |
||
| 105 | ); |
||
| 106 | |||
| 107 | exit(EXIT_SUCCESS); |
||
| 108 | } |
||
| 110 | } |
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.