FilterFactoryCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A getFilterFactoryByName() 0 8 2
A getAll() 0 4 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\Config;
13
14
use Liip\ImagineBundle\Exception\Config\Filter\NotFoundException;
15
use Liip\ImagineBundle\Factory\Config\FilterFactoryInterface;
16
17
class FilterFactoryCollection
18
{
19
    /**
20
     * @var FilterFactoryInterface[]
21
     */
22
    private $filterFactories = [];
23
24
    /**
25
     * @param FilterFactoryInterface ...$filterFactories
26
     */
27
    public function __construct(FilterFactoryInterface ...$filterFactories)
28
    {
29
        foreach ($filterFactories as $filterFactory) {
30
            $this->filterFactories[$filterFactory->getName()] = $filterFactory;
31
        }
32
    }
33
34
    /**
35
     * @throws NotFoundException
36
     */
37
    public function getFilterFactoryByName(string $name): FilterFactoryInterface
38
    {
39
        if (!isset($this->filterFactories[$name])) {
40
            throw new NotFoundException(sprintf("Filter factory with name '%s' was not found.", $name));
41
        }
42
43
        return $this->filterFactories[$name];
44
    }
45
46
    /**
47
     * @return FilterFactoryInterface[]
48
     */
49
    public function getAll()
50
    {
51
        return $this->filterFactories;
52
    }
53
}
54