Conditions | 7 |
Paths | 6 |
Total Lines | 51 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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): void |
||
25 | { |
||
26 | if (!$container->hasDefinition(DoctrineProvider::class)) { |
||
27 | return; |
||
28 | } |
||
29 | |||
30 | $doctrineProviderConfigurationKey = 'dh_auditor.provider.doctrine.configuration'; |
||
31 | if (!$container->hasParameter($doctrineProviderConfigurationKey)) { |
||
32 | return; |
||
33 | } |
||
34 | |||
35 | $providerDefinition = $container->getDefinition(DoctrineProvider::class); |
||
36 | $config = $container->getParameter($doctrineProviderConfigurationKey); |
||
37 | |||
38 | \assert(\is_array($config) && \array_key_exists('storage_services', $config)); |
||
39 | foreach (array_unique($config['storage_services']) as $entityManagerName) { |
||
40 | $entityManagerName = str_replace('@', '', $entityManagerName); |
||
41 | $entityManagerReference = new Reference($entityManagerName); |
||
42 | |||
43 | $service = 'dh_auditor.provider.doctrine.storage_services.'.$entityManagerName; |
||
44 | $serviceDefinition = new Definition(StorageService::class, [ |
||
45 | $service, |
||
46 | $entityManagerReference, |
||
47 | ]); |
||
48 | $container->setDefinition($service, $serviceDefinition); |
||
49 | $serviceReference = new Reference($service); |
||
50 | |||
51 | $providerDefinition->addMethodCall('registerStorageService', [$serviceReference]); |
||
52 | } |
||
53 | |||
54 | \assert(\is_array($config) && \array_key_exists('auditing_services', $config)); |
||
55 | |||
56 | $this->registerDHMiddleware($container); |
||
57 | |||
58 | foreach (array_unique($config['auditing_services']) as $entityManagerName) { |
||
59 | $entityManagerName = str_replace('@', '', $entityManagerName); |
||
60 | $entityManagerReference = new Reference($entityManagerName); |
||
61 | |||
62 | $service = 'dh_auditor.provider.doctrine.auditing_services.'.$entityManagerName; |
||
63 | $serviceDefinition = new Definition(AuditingService::class, [ |
||
64 | $service, |
||
65 | $entityManagerReference, |
||
66 | ]); |
||
67 | $container->setDefinition($service, $serviceDefinition); |
||
68 | $serviceReference = new Reference($service); |
||
69 | |||
70 | $annotationLoaderDefinition = new Definition(AnnotationLoader::class, [$entityManagerReference]); |
||
71 | $container->setDefinition(AnnotationLoader::class, $annotationLoaderDefinition); |
||
72 | |||
73 | $providerDefinition->addMethodCall('registerAuditingService', [$serviceReference]); |
||
74 | $this->configureDHMiddleware($container, $entityManagerName); |
||
75 | } |
||
114 |