AbstractLoaderFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getChildLoaderDefinition() 0 4 1
A setTaggedLoaderDefinition() 0 15 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\DependencyInjection\ChildDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
18
abstract class AbstractLoaderFactory implements LoaderFactoryInterface
19
{
20
    /**
21
     * @var string
22
     */
23
    protected static $namePrefix = 'liip_imagine.binary.loader';
24
25
    /**
26
     * @return ChildDefinition
27
     */
28
    final protected function getChildLoaderDefinition()
29
    {
30
        return new ChildDefinition(sprintf('%s.prototype.%s', static::$namePrefix, $this->getName()));
31
    }
32
33
    /**
34
     * @param string $name
35
     *
36
     * @return string
37
     */
38
    final protected function setTaggedLoaderDefinition($name, Definition $definition, ContainerBuilder $container)
39
    {
40
        $definition->addTag(static::$namePrefix, [
41
            'loader' => $name,
42
        ]);
43
44
        $definition->setPublic(true);
45
46
        $container->setDefinition(
47
            $id = sprintf('%s.%s', static::$namePrefix, $name),
48
            $definition
49
        );
50
51
        return $id;
52
    }
53
}
54