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