Completed
Push — master ( 0a7932...aee286 )
by Maksim
13s
created

FilterConfiguration   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

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