Completed
Pull Request — master (#1258)
by
unknown
01:33
created

FormatResolverFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 14
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 14 14 1
A getName() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Liip\ImagineBundle\DependencyInjection\Factory\Resolver;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\DefinitionDecorator;
7
8
/**
9
 * Class FormatResolverFactory
10
 *
11
 * @copyright 2017 IntechSystems, SIA
12
 * @package   Liip\ImagineBundle\DependencyInjection\Factory\Resolver
13
 * @author    Mihail Savluga
14
 */
15
class FormatResolverFactory extends WebPathResolverFactory
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20 View Code Duplication
    public function create(ContainerBuilder $container, $resolverName, array $config)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $resolverDefinition = new DefinitionDecorator('liip_imagine.cache.resolver.prototype.format');
23
        $resolverDefinition->replaceArgument(2, $config['web_root']);
24
        $resolverDefinition->replaceArgument(3, $config['cache_prefix']);
25
        $resolverDefinition->addTag('liip_imagine.cache.resolver', array(
26
            'resolver' => $resolverName
27
        ));
28
        $resolverId = 'liip_imagine.cache.resolver.'.$resolverName;
29
30
        $container->setDefinition($resolverId, $resolverDefinition);
31
32
        return $resolverId;
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function getName()
39
    {
40
        return 'format';
41
    }
42
}
43