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