| Conditions | 5 |
| Paths | 16 |
| Total Lines | 57 |
| Code Lines | 37 |
| Lines | 22 |
| Ratio | 38.6 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 16 | public function create(ContainerBuilder $container, $resolverName, array $config) |
||
| 17 | { |
||
| 18 | $awsS3ClientId = 'liip_imagine.cache.resolver.'.$resolverName.'.client'; |
||
| 19 | $awsS3ClientDefinition = new Definition('Aws\S3\S3Client'); |
||
| 20 | if (method_exists($awsS3ClientDefinition, 'setFactory')) { |
||
| 21 | $awsS3ClientDefinition->setFactory(array('Aws\S3\S3Client', 'factory')); |
||
| 22 | } else { |
||
| 23 | // to be removed when dependency on Symfony DependencyInjection is bumped to 2.6 |
||
| 24 | $awsS3ClientDefinition->setFactoryClass('Aws\S3\S3Client'); |
||
|
|
|||
| 25 | $awsS3ClientDefinition->setFactoryMethod('factory'); |
||
| 26 | } |
||
| 27 | $awsS3ClientDefinition->addArgument($config['client_config']); |
||
| 28 | $container->setDefinition($awsS3ClientId, $awsS3ClientDefinition); |
||
| 29 | |||
| 30 | $resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.aws_s3'); |
||
| 31 | $resolverDefinition->replaceArgument(0, new Reference($awsS3ClientId)); |
||
| 32 | $resolverDefinition->replaceArgument(1, $config['bucket']); |
||
| 33 | $resolverDefinition->replaceArgument(2, $config['acl']); |
||
| 34 | $resolverDefinition->replaceArgument(3, array_replace($config['url_options'], $config['get_options'])); |
||
| 35 | $resolverDefinition->replaceArgument(4, $config['put_options']); |
||
| 36 | $resolverId = 'liip_imagine.cache.resolver.'.$resolverName; |
||
| 37 | $container->setDefinition($resolverId, $resolverDefinition); |
||
| 38 | |||
| 39 | if (isset($config['cache_prefix'])) { |
||
| 40 | $resolverDefinition->addMethodCall('setCachePrefix', array($config['cache_prefix'])); |
||
| 41 | } |
||
| 42 | |||
| 43 | View Code Duplication | if ($config['proxies']) { |
|
| 44 | $proxiedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.proxied'; |
||
| 45 | |||
| 46 | $container->setDefinition($proxiedResolverId, $resolverDefinition); |
||
| 47 | |||
| 48 | $proxyResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.proxy'); |
||
| 49 | $proxyResolverDefinition->replaceArgument(0, new Reference($proxiedResolverId)); |
||
| 50 | $proxyResolverDefinition->replaceArgument(1, $config['proxies']); |
||
| 51 | |||
| 52 | $container->setDefinition($resolverId, $proxyResolverDefinition); |
||
| 53 | } |
||
| 54 | |||
| 55 | View Code Duplication | if ($config['cache']) { |
|
| 56 | $cachedResolverId = 'liip_imagine.cache.resolver.'.$resolverName.'.cached'; |
||
| 57 | |||
| 58 | $container->setDefinition($cachedResolverId, $container->getDefinition($resolverId)); |
||
| 59 | |||
| 60 | $cacheResolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.cache'); |
||
| 61 | $cacheResolverDefinition->replaceArgument(0, new Reference($config['cache'])); |
||
| 62 | $cacheResolverDefinition->replaceArgument(1, new Reference($cachedResolverId)); |
||
| 63 | |||
| 64 | $container->setDefinition($resolverId, $cacheResolverDefinition); |
||
| 65 | } |
||
| 66 | |||
| 67 | $container->getDefinition($resolverId)->addTag('liip_imagine.cache.resolver', array( |
||
| 68 | 'resolver' => $resolverName, |
||
| 69 | )); |
||
| 70 | |||
| 71 | return $resolverId; |
||
| 72 | } |
||
| 73 | |||
| 121 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.