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