| Conditions | 10 |
| Paths | 130 |
| Total Lines | 58 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 24 | public function process(ContainerBuilder $container) |
||
| 25 | { |
||
| 26 | $config = $container->getExtensionConfig('pgs_restfony')[0]; |
||
| 27 | |||
| 28 | if (!isset($config['modules'])) { |
||
| 29 | return false; |
||
| 30 | } |
||
| 31 | |||
| 32 | foreach ($config['modules'] as $moduleName => $module) { |
||
| 33 | $serviceAlias = 'pgs.rest.manager.'.$moduleName; |
||
| 34 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 35 | $managerDefinition = (new ManagerDefinition())->create($module['manager'], $module['entity']); |
||
| 36 | $container->setDefinition($serviceAlias, $managerDefinition); |
||
| 37 | } |
||
| 38 | |||
| 39 | $serviceAlias = 'pgs.rest.form.'.$moduleName; |
||
| 40 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 41 | $formDefinition = (new FormTypeDefinition())->create($moduleName, $module['form']); |
||
| 42 | $container->setDefinition($serviceAlias, $formDefinition); |
||
| 43 | } |
||
| 44 | |||
| 45 | $serviceAlias = 'pgs.rest.form_filter.'.$moduleName; |
||
| 46 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 47 | $formFilterDefinition = (new FormFilterTypeDefinition())->create($moduleName, $module['filter']); |
||
| 48 | $container->setDefinition($serviceAlias, $formFilterDefinition); |
||
| 49 | } |
||
| 50 | |||
| 51 | $serviceAlias = 'pgs.rest.form_factory.'.$moduleName; |
||
| 52 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 53 | $formFactoryDefinition = (new FormFactoryDefinition())->create($moduleName); |
||
| 54 | $container->setDefinition($serviceAlias, $formFactoryDefinition); |
||
| 55 | } |
||
| 56 | |||
| 57 | $serviceAlias = 'pgs.rest.filter_factory.'.$moduleName; |
||
| 58 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 59 | $formFactoryDefinition = (new FilterFactoryDefinition())->create($moduleName); |
||
| 60 | $container->setDefinition($serviceAlias, $formFactoryDefinition); |
||
| 61 | } |
||
| 62 | |||
| 63 | $serviceAlias = 'pgs.rest.rest_manager.'.$moduleName; |
||
| 64 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 65 | $restManagerDefinition = (new RestManagerDefinition())->create($moduleName); |
||
| 66 | $container->setDefinition($serviceAlias, $restManagerDefinition); |
||
| 67 | } |
||
| 68 | |||
| 69 | $serviceAlias = 'pgs.rest.controller.'.$moduleName; |
||
| 70 | if (!$container->hasDefinition($serviceAlias)) { |
||
| 71 | $controllerDefinition = (new ControllerFactoryDefinition())->create( |
||
| 72 | $moduleName, |
||
| 73 | $module['controller'], |
||
| 74 | $module['sorts'] |
||
| 75 | ); |
||
| 76 | $container->setDefinition($serviceAlias, $controllerDefinition); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | return true; |
||
| 81 | } |
||
| 82 | } |
||
| 83 |