Conditions | 6 |
Paths | 11 |
Total Lines | 75 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
61 | public function execute() |
||
62 | { |
||
63 | $this->__callOptions(); |
||
64 | |||
65 | if (empty($this->optionName)) { |
||
66 | output()->write( |
||
|
|||
67 | (new Format()) |
||
68 | ->setContextualClass(Format::DANGER) |
||
69 | ->setString(language()->getLine('CLI_MAKE_APP_E_NAME')) |
||
70 | ->setNewLinesAfter(1) |
||
71 | ); |
||
72 | |||
73 | exit(EXIT_ERROR); |
||
74 | } |
||
75 | |||
76 | $moduleType = empty($this->moduleType) |
||
77 | ? 'App' |
||
78 | : ucfirst(plural($this->moduleType)); |
||
79 | |||
80 | $modulePath = PATH_APP . studlycase($this->optionName) . DIRECTORY_SEPARATOR; |
||
81 | |||
82 | if ( ! is_dir($modulePath)) { |
||
83 | mkdir($modulePath, 0777, true); |
||
84 | } else { |
||
85 | output()->write( |
||
86 | (new Format()) |
||
87 | ->setContextualClass(Format::DANGER) |
||
88 | ->setString(language()->getLine('CLI_MAKE_APP_E_EXISTS', [$modulePath])) |
||
89 | ->setNewLinesAfter(1) |
||
90 | ); |
||
91 | |||
92 | exit(EXIT_ERROR); |
||
93 | } |
||
94 | |||
95 | $jsonProperties[ 'name' ] = readable( |
||
96 | pathinfo($modulePath, PATHINFO_FILENAME), |
||
97 | true |
||
98 | ); |
||
99 | |||
100 | if (empty($this->namespace)) { |
||
101 | $namespace = loader()->getDirNamespace('') . |
||
102 | $moduleType . '\\' . prepare_class_name( |
||
103 | $this->optionName |
||
104 | ) . '\\'; |
||
105 | } else { |
||
106 | $namespace = $this->namespace; |
||
107 | $jsonProperties[ 'namespace' ] = rtrim($namespace, '\\') . '\\'; |
||
108 | } |
||
109 | |||
110 | $jsonProperties[ 'created' ] = date('d M Y'); |
||
111 | |||
112 | loader()->addNamespace($namespace, $modulePath); |
||
113 | |||
114 | $fileContent = json_encode($jsonProperties, JSON_PRETTY_PRINT); |
||
115 | |||
116 | $filePath = $modulePath . strtolower(singular($moduleType)) . '.json'; |
||
117 | |||
118 | file_put_contents($filePath, $fileContent); |
||
119 | |||
120 | $this->optionPath = $modulePath; |
||
121 | $this->optionFilename = prepare_filename($this->optionName) . '.php'; |
||
122 | |||
123 | (new Controller()) |
||
124 | ->optionPath($this->optionPath) |
||
125 | ->optionFilename($this->optionFilename); |
||
126 | |||
127 | if (is_dir($modulePath)) { |
||
128 | output()->write( |
||
129 | (new Format()) |
||
130 | ->setContextualClass(Format::SUCCESS) |
||
131 | ->setString(language()->getLine('CLI_MAKE_APP_S_MAKE', [$modulePath])) |
||
132 | ->setNewLinesAfter(1) |
||
133 | ); |
||
134 | |||
135 | exit(EXIT_SUCCESS); |
||
136 | } |
||
138 | } |
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.