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

FilterConfiguration::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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