| Conditions | 2 |
| Paths | 2 |
| Total Lines | 112 |
| 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 | $path = __DIR__.'/../Resources/skeleton/'; |
||
| 121 | |||
| 122 | $generator->generateClass( |
||
| 123 | $controllerClassNameDetails->getFullName(), |
||
| 124 | $path.'controller/Controller.tpl.php', |
||
| 125 | [ |
||
| 126 | 'entity_full_class_name' => $entityClassNameDetails->getFullName(), |
||
| 127 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 128 | 'form_full_class_name' => $formClassNameDetails->getFullName(), |
||
| 129 | 'form_class_name' => $formClassNameDetails->getShortName(), |
||
| 130 | 'route_path' => Str::asRoutePath($controllerClassNameDetails->getRelativeNameWithoutSuffix()), |
||
| 131 | 'route_name' => $routeName, |
||
| 132 | 'entity_var_plural' => $entityVarPlural, |
||
| 133 | 'entity_var_singular' => $entityVarSingular, |
||
| 134 | 'entity_identifier' => $metadata->identifier[0], |
||
| 135 | ] |
||
| 136 | ); |
||
| 137 | |||
| 138 | $helper = new GeneratorHelper(); |
||
| 139 | |||
| 140 | $generator->generateClass( |
||
| 141 | $formClassNameDetails->getFullName(), |
||
| 142 | $path.'form/Type.tpl.php', |
||
| 143 | [ |
||
| 144 | 'entity_class_exists' => true, |
||
| 145 | 'entity_full_class_name' => $entityClassNameDetails->getFullName(), |
||
| 146 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 147 | 'form_fields' => $this->getFormFieldsFromEntity($metadata), |
||
| 148 | ] |
||
| 149 | ); |
||
| 150 | |||
| 151 | $baseLayoutExists = true; |
||
| 152 | $templatesPath = Str::asFilePath($controllerClassNameDetails->getRelativeNameWithoutSuffix()); |
||
| 153 | |||
| 154 | $templates = [ |
||
| 155 | '_delete_form' => [ |
||
| 156 | 'route_name' => $routeName, |
||
| 157 | 'entity_identifier' => $metadata->identifier[0], |
||
| 158 | ], |
||
| 159 | '_form' => [], |
||
| 160 | 'edit' => [ |
||
| 161 | 'helper' => $helper, |
||
| 162 | 'base_layout_exists' => $baseLayoutExists, |
||
| 163 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 164 | 'entity_var_singular' => $entityVarSingular, |
||
| 165 | 'entity_identifier' => $metadata->identifier[0], |
||
| 166 | 'route_name' => $routeName, |
||
| 167 | ], |
||
| 168 | 'index' => [ |
||
| 169 | 'helper' => $helper, |
||
| 170 | 'base_layout_exists' => $baseLayoutExists, |
||
| 171 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 172 | 'entity_var_plural' => $entityVarPlural, |
||
| 173 | 'entity_var_singular' => $entityVarSingular, |
||
| 174 | 'entity_identifier' => $metadata->identifier[0], |
||
| 175 | 'entity_fields' => $metadata->fieldMappings, |
||
| 176 | 'route_name' => $routeName, |
||
| 177 | ], |
||
| 178 | 'new' => [ |
||
| 179 | 'helper' => $helper, |
||
| 180 | 'base_layout_exists' => $baseLayoutExists, |
||
| 181 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 182 | 'route_name' => $routeName, |
||
| 183 | ], |
||
| 184 | 'show' => [ |
||
| 185 | 'helper' => $helper, |
||
| 186 | 'base_layout_exists' => $baseLayoutExists, |
||
| 187 | 'entity_class_name' => $entityClassNameDetails->getShortName(), |
||
| 188 | 'entity_var_singular' => $entityVarSingular, |
||
| 189 | 'entity_identifier' => $metadata->identifier[0], |
||
| 190 | 'entity_fields' => $metadata->fieldMappings, |
||
| 191 | 'route_name' => $routeName, |
||
| 192 | ], |
||
| 193 | ]; |
||
| 194 | |||
| 195 | foreach ($templates as $template => $variables) { |
||
| 196 | $generator->generateFile( |
||
| 197 | 'templates/'.$templatesPath.'/'.$template.'.html.twig', |
||
| 198 | $path.'templates/'.$template.'.tpl.php', |
||
| 199 | $variables |
||
| 200 | ); |
||
| 201 | } |
||
| 202 | |||
| 203 | $generator->writeChanges(); |
||
| 204 | |||
| 205 | $this->writeSuccessMessage($io); |
||
| 206 | |||
| 207 | $io->text('Next: Check your new CRUD!'); |
||
| 208 | } |
||
| 226 |
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