FilterConfiguration   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 8 2
A set() 0 4 1
A all() 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\Imagine\Filter;
13
14
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
15
16
class FilterConfiguration
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $filters = [];
22
23
    public function __construct(array $filters = [])
24
    {
25
        $this->filters = $filters;
26
    }
27
28
    /**
29
     * Gets a previously configured filter.
30
     *
31
     * @param string $filter
32
     *
33
     * @throws NonExistingFilterException
34
     *
35
     * @return array
36
     */
37
    public function get($filter)
38
    {
39
        if (false === \array_key_exists($filter, $this->filters)) {
40
            throw new NonExistingFilterException(sprintf('Could not find configuration for a filter: %s', $filter));
41
        }
42
43
        return $this->filters[$filter];
44
    }
45
46
    /**
47
     * Sets a configuration on the given filter.
48
     *
49
     * @param string $filter
50
     */
51
    public function set($filter, array $config)
52
    {
53
        $this->filters[$filter] = $config;
54
    }
55
56
    /**
57
     * Get all filters.
58
     *
59
     * @return array
60
     */
61
    public function all()
62
    {
63
        return $this->filters;
64
    }
65
}
66