Conditions | 2 |
Paths | 2 |
Total Lines | 111 |
Code Lines | 80 |
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 |
||
96 | public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator) |
||
97 | { |
||
98 | $entityClassNameDetails = $generator->createClassNameDetails( |
||
99 | $input->getArgument('entity-class'), |
||
100 | 'Entity\\' |
||
101 | ); |
||
102 | |||
103 | $controllerClassNameDetails = $generator->createClassNameDetails( |
||
104 | $entityClassNameDetails->getRelativeNameWithoutSuffix(), |
||
105 | 'Controller\\', |
||
106 | 'Controller' |
||
107 | ); |
||
108 | |||
109 | $formClassNameDetails = $generator->createClassNameDetails( |
||
110 | $entityClassNameDetails->getRelativeNameWithoutSuffix(), |
||
111 | 'Form\\', |
||
112 | 'Type' |
||
113 | ); |
||
114 | |||
115 | $metadata = $this->entityManager->getClassMetadata($entityClassNameDetails->getFullName()); |
||
116 | $entityVarPlural = lcfirst(Inflector::pluralize($entityClassNameDetails->getShortName())); |
||
117 | $entityVarSingular = lcfirst(Inflector::singularize($entityClassNameDetails->getShortName())); |
||
118 | $routeName = Str::asRouteName($controllerClassNameDetails->getRelativeNameWithoutSuffix()); |
||
119 | |||
120 | $generator->generateClass( |
||
121 | $controllerClassNameDetails->getFullName(), |
||
122 | 'crud/controller/Controller.tpl.php', |
||
123 | [ |
||
124 | 'entity_full_class_name' => $entityClassNameDetails->getFullName(), |
||
125 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
126 | 'form_full_class_name' => $formClassNameDetails->getFullName(), |
||
127 | 'form_class_name' => $formClassNameDetails->getShortName(), |
||
128 | 'route_path' => Str::asRoutePath($controllerClassNameDetails->getRelativeNameWithoutSuffix()), |
||
129 | 'route_name' => $routeName, |
||
130 | 'entity_var_plural' => $entityVarPlural, |
||
131 | 'entity_var_singular' => $entityVarSingular, |
||
132 | 'entity_identifier' => $metadata->identifier[0], |
||
133 | ] |
||
134 | ); |
||
135 | |||
136 | $helper = new GeneratorHelper(); |
||
137 | |||
138 | $generator->generateClass( |
||
139 | $formClassNameDetails->getFullName(), |
||
140 | 'form/crud/Type.tpl.php', |
||
141 | [ |
||
142 | 'entity_class_exists' => true, |
||
143 | 'entity_full_class_name' => $entityClassNameDetails->getFullName(), |
||
144 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
145 | 'entity_fields' => $metadata->fieldMappings, |
||
146 | 'helper' => $helper, |
||
147 | ] |
||
148 | ); |
||
149 | |||
150 | $baseLayoutExists = true; |
||
151 | $templatesPath = Str::asFilePath($controllerClassNameDetails->getRelativeNameWithoutSuffix()); |
||
152 | |||
153 | $templates = [ |
||
154 | '_delete_form' => [ |
||
155 | 'route_name' => $routeName, |
||
156 | 'entity_identifier' => $metadata->identifier[0], |
||
157 | ], |
||
158 | '_form' => [], |
||
159 | 'edit' => [ |
||
160 | 'helper' => $helper, |
||
161 | 'base_layout_exists' => $baseLayoutExists, |
||
162 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
163 | 'entity_var_singular' => $entityVarSingular, |
||
164 | 'entity_identifier' => $metadata->identifier[0], |
||
165 | 'route_name' => $routeName, |
||
166 | ], |
||
167 | 'index' => [ |
||
168 | 'helper' => $helper, |
||
169 | 'base_layout_exists' => $baseLayoutExists, |
||
170 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
171 | 'entity_var_plural' => $entityVarPlural, |
||
172 | 'entity_var_singular' => $entityVarSingular, |
||
173 | 'entity_identifier' => $metadata->identifier[0], |
||
174 | 'entity_fields' => $metadata->fieldMappings, |
||
175 | 'route_name' => $routeName, |
||
176 | ], |
||
177 | 'new' => [ |
||
178 | 'helper' => $helper, |
||
179 | 'base_layout_exists' => $baseLayoutExists, |
||
180 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
181 | 'route_name' => $routeName, |
||
182 | ], |
||
183 | 'show' => [ |
||
184 | 'helper' => $helper, |
||
185 | 'base_layout_exists' => $baseLayoutExists, |
||
186 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
187 | 'entity_var_singular' => $entityVarSingular, |
||
188 | 'entity_identifier' => $metadata->identifier[0], |
||
189 | 'entity_fields' => $metadata->fieldMappings, |
||
190 | 'route_name' => $routeName, |
||
191 | ], |
||
192 | ]; |
||
193 | |||
194 | foreach ($templates as $template => $variables) { |
||
195 | $generator->generateFile( |
||
196 | 'templates/'.$templatesPath.'/'.$template.'.html.twig', |
||
197 | 'crud/templates/'.$template.'.tpl.php', |
||
198 | $variables |
||
199 | ); |
||
200 | } |
||
201 | |||
202 | $generator->writeChanges(); |
||
203 | |||
204 | $this->writeSuccessMessage($io); |
||
205 | |||
206 | $io->text('Next: Check your new crud!'); |
||
207 | } |
||
209 |
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