Conditions | 10 |
Paths | 6 |
Total Lines | 33 |
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 |
||
24 | public function process(ContainerBuilder $container): void |
||
25 | { |
||
26 | if (!$container->hasDefinition('simplethings_entityaudit.config')) { |
||
27 | return; |
||
28 | } |
||
29 | |||
30 | $auditedEntities = $container->getParameter('simplethings.entityaudit.audited_entities'); |
||
31 | $force = $container->getParameter('sonata_doctrine_orm_admin.audit.force'); |
||
32 | |||
33 | foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) { |
||
34 | if ('orm' !== $attributes[0]['manager_type']) { |
||
35 | continue; |
||
36 | } |
||
37 | |||
38 | if (true === $force && isset($attributes[0]['audit']) && false === $attributes[0]['audit']) { |
||
39 | continue; |
||
40 | } |
||
41 | |||
42 | if (false === $force && (!isset($attributes[0]['audit']) || false === $attributes[0]['audit'])) { |
||
43 | continue; |
||
44 | } |
||
45 | |||
46 | $definition = $container->getDefinition($id); |
||
47 | $auditedEntities[] = $this->getModelName($container, $definition->getArgument(1)); |
||
48 | } |
||
49 | |||
50 | $auditedEntities = array_unique($auditedEntities); |
||
51 | |||
52 | $container->setParameter('simplethings.entityaudit.audited_entities', $auditedEntities); |
||
53 | |||
54 | $auditManager = $container->getDefinition('sonata.admin.audit.manager'); |
||
55 | $auditManager->addMethodCall('setReader', ['sonata.admin.audit.orm.reader', $auditedEntities]); |
||
56 | } |
||
57 | |||
67 |