Conditions | 6 |
Paths | 13 |
Total Lines | 74 |
Code Lines | 52 |
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_HELPER_E_FILENAME')) |
||
53 | ->setNewLinesAfter(1) |
||
54 | ); |
||
55 | |||
56 | exit(EXIT_ERROR); |
||
57 | } |
||
58 | |||
59 | if (strpos($this->optionPath, 'Helpers') === false) { |
||
60 | $filePath = $this->optionPath . 'Helpers' . DIRECTORY_SEPARATOR . $this->optionFilename; |
||
61 | } else { |
||
62 | $filePath = $this->optionPath . $this->optionFilename; |
||
63 | } |
||
64 | |||
65 | if ( ! is_dir(dirname($filePath))) { |
||
66 | mkdir(dirname($filePath), 0777, true); |
||
67 | } |
||
68 | |||
69 | if (is_file($filePath)) { |
||
70 | output()->write( |
||
71 | (new Format()) |
||
72 | ->setContextualClass(Format::DANGER) |
||
73 | ->setString(language()->getLine('CLI_MAKE_HELPER_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[ 'HELPER' ] = underscore( |
||
82 | snakecase( |
||
83 | pathinfo($filePath, PATHINFO_FILENAME) |
||
84 | ) |
||
85 | ); |
||
86 | $vars[ 'FILEPATH' ] = $filePath; |
||
87 | |||
88 | $phpTemplate = <<<PHPTEMPLATE |
||
89 | <?php |
||
90 | /** |
||
91 | * Created by O2System Reactor File Generator. |
||
92 | * DateTime: CREATE_DATETIME |
||
93 | */ |
||
94 | |||
95 | // ------------------------------------------------------------------------ |
||
96 | |||
97 | if ( ! function_exists( 'HELPER' ) ) { |
||
98 | /** |
||
99 | * HELPER |
||
100 | */ |
||
101 | function HELPER() { |
||
102 | } |
||
103 | } |
||
104 | PHPTEMPLATE; |
||
105 | |||
106 | $fileContent = str_replace(array_keys($vars), array_values($vars), $phpTemplate); |
||
107 | file_put_contents($filePath, $fileContent); |
||
108 | |||
109 | if (is_file($filePath)) { |
||
110 | output()->write( |
||
111 | (new Format()) |
||
112 | ->setContextualClass(Format::SUCCESS) |
||
113 | ->setString(language()->getLine('CLI_MAKE_HELPER_S_MAKE', [$filePath])) |
||
114 | ->setNewLinesAfter(1) |
||
115 | ); |
||
116 | |||
117 | exit(EXIT_SUCCESS); |
||
118 | } |
||
120 | } |
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.