Conditions | 10 |
Paths | 3 |
Total Lines | 27 |
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 |
||
28 | public function process(ContainerBuilder $container): void |
||
29 | { |
||
30 | $translationTargets = $container->getParameter('sonata_translation.targets'); |
||
31 | $adminExtensionReferences = $this->getAdminExtensionReferenceByTypes(array_keys($translationTargets)); |
||
32 | |||
33 | foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) { |
||
34 | $admin = $container->getDefinition($id); |
||
35 | $modelClass = $container->getParameterBag()->resolveValue($admin->getArgument(1)); |
||
36 | if (!$modelClass || !class_exists($modelClass)) { |
||
37 | continue; |
||
38 | } |
||
39 | $modelClassReflection = new \ReflectionClass($modelClass); |
||
40 | |||
41 | foreach ($adminExtensionReferences as $type => $reference) { |
||
42 | foreach ($translationTargets[$type]['implements'] as $interface) { |
||
43 | if ($modelClassReflection->implementsInterface($interface)) { |
||
44 | $admin->addMethodCall('addExtension', [$reference]); |
||
45 | } |
||
46 | } |
||
47 | foreach ($translationTargets[$type]['instanceof'] as $class) { |
||
48 | if ($modelClassReflection->getName() === $class || $modelClassReflection->isSubclassOf($class)) { |
||
|
|||
49 | $admin->addMethodCall('addExtension', [$reference]); |
||
50 | } |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | } |
||
55 | |||
69 |