Completed
Pull Request — master (#732)
by 12345
03:41
created

StreamLoaderFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 41
loc 41
wmc 3
c 1
b 1
f 0
lcom 0
cbo 5
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A create() 14 14 1
A addConfiguration() 9 9 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\Loader;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\DefinitionDecorator;
8
9 View Code Duplication
class StreamLoaderFactory implements LoaderFactoryInterface
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function create(ContainerBuilder $container, $loaderName, array $config)
15
    {
16
        $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.stream');
17
        $loaderDefinition->replaceArgument(0, $config['wrapper']);
18
        $loaderDefinition->replaceArgument(1, $config['context']);
19
        $loaderDefinition->addTag('liip_imagine.binary.loader', array(
20
            'loader' => $loaderName,
21
        ));
22
        $loaderId = 'liip_imagine.binary.loader.'.$loaderName;
23
24
        $container->setDefinition($loaderId, $loaderDefinition);
25
26
        return $loaderId;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getName()
33
    {
34
        return 'stream';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function addConfiguration(ArrayNodeDefinition $builder)
41
    {
42
        $builder
43
            ->children()
44
                ->scalarNode('wrapper')->isRequired()->cannotBeEmpty()->end()
45
                ->scalarNode('context')->defaultValue(null)->end()
46
            ->end()
47
        ;
48
    }
49
}
50