Conditions | 11 |
Paths | 11 |
Total Lines | 66 |
Code Lines | 51 |
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 |
||
161 | protected function generate($path, $folder, $type,$form ='') |
||
162 | { |
||
163 | $content = $this->getStub($type); |
||
164 | |||
165 | if($content === false) |
||
166 | { |
||
167 | echo 'file '.$type.".stub is not exist !"; |
||
168 | return false; |
||
169 | } |
||
170 | |||
171 | $template = str_replace( |
||
172 | [ |
||
173 | '{{modelName}}', |
||
174 | '{{lcPluralModelName}}', |
||
175 | "{{folder}}", |
||
176 | "{{path}}", |
||
177 | "{{modelBaseFolderName}}", |
||
178 | "{{interfaceBaseFolderName}}", |
||
179 | "{{form}}", |
||
180 | ], |
||
181 | [ |
||
182 | $this->repoName, |
||
183 | str_plural(lcfirst($this->repoName)), |
||
184 | str_plural($folder), |
||
185 | $path, |
||
186 | str_plural(\Config::get('repository.model','Entity')), |
||
187 | str_plural(\Config::get('repository.interface','Interface')), |
||
188 | $form |
||
189 | ], |
||
190 | $this->getStub($type) |
||
191 | ); |
||
192 | |||
193 | $folder = str_replace('\\','/',$folder); |
||
194 | $path = str_replace('\\','/',$path); |
||
195 | |||
196 | switch ($type) |
||
197 | { |
||
198 | case 'Entity': |
||
199 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
||
200 | $filePath = rtrim($filePath,'/'); |
||
201 | $filePath .= "/"; |
||
202 | file_put_contents($filePath . "{$this->repoName}.php", $template); |
||
203 | break; |
||
204 | case 'Controller': |
||
205 | case 'Request': |
||
206 | case 'Repository': |
||
207 | case 'Interface': |
||
208 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
||
209 | $filePath = rtrim($filePath,'/'); |
||
210 | $filePath .= "/"; |
||
211 | file_put_contents($filePath . "{$this->repoName}{$type}.php", $template); |
||
212 | break; |
||
213 | case 'create': |
||
214 | case 'edit': |
||
215 | case 'index': |
||
216 | case 'show': |
||
217 | $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/"; |
||
218 | $repoName = lcfirst($type); |
||
219 | file_put_contents($filePath . $repoName.".blade.php", $template); |
||
220 | break; |
||
221 | default: |
||
222 | $filePath = $this->getFolderOrCreate($folder)."/"; |
||
223 | $repoName = lcfirst($this->repoName); |
||
224 | file_put_contents($filePath . $repoName.".php", $template); |
||
225 | } |
||
226 | return true; |
||
227 | } |
||
242 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths