Completed
Push — master ( bf3f93...22d625 )
by Maksim
03:11
created

FlysystemLoaderFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 13
loc 13
rs 9.4286
cc 1
eloc 8
nc 1
nop 3
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
use Symfony\Component\DependencyInjection\Reference;
9
10 View Code Duplication
class FlysystemLoaderFactory 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...
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function create(ContainerBuilder $container, $loaderName, array $config)
16
    {
17
        $loaderDefinition = new DefinitionDecorator('liip_imagine.binary.loader.prototype.flysystem');
18
        $loaderDefinition->replaceArgument(1, new Reference($config['filesystem_service']));
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 'flysystem';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function addConfiguration(ArrayNodeDefinition $builder)
41
    {
42
        $builder
43
            ->children()
44
                ->scalarNode('filesystem_service')->isRequired()->cannotBeEmpty()->end()
45
            ->end()
46
        ;
47
    }
48
}
49