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