FlysystemLoaderFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 7
dl 0
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 2
A getName() 0 4 1
A addConfiguration() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\DependencyInjection\Factory\Loader;
13
14
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18
class FlysystemLoaderFactory extends AbstractLoaderFactory
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function create(ContainerBuilder $container, $loaderName, array $config)
24
    {
25
        $definition = $this->getChildLoaderDefinition();
26
27
        if ($container->hasDefinition('liip_imagine.mime_types')) {
28
            $mimeTypes = $container->getDefinition('liip_imagine.mime_types');
29
            $definition->replaceArgument(0, $mimeTypes);
30
        }
31
32
        $definition->replaceArgument(1, new Reference($config['filesystem_service']));
33
34
        return $this->setTaggedLoaderDefinition($loaderName, $definition, $container);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getName()
41
    {
42
        return 'flysystem';
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function addConfiguration(ArrayNodeDefinition $builder)
49
    {
50
        $builder
51
            ->children()
52
                ->scalarNode('filesystem_service')
53
                    ->isRequired()
54
                    ->cannotBeEmpty()
55
                ->end()
56
            ->end();
57
    }
58
}
59