Completed
Pull Request — 2.0 (#1098)
by
unknown
10:38 queued 07:38
created

StackCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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
final class StackCollection
15
{
16
    /**
17
     * @var array
18
     */
19
    private $filterSets = [];
20
21
    /**
22
     * @var StackBuilderInterface
23
     */
24
    private $filterSetBuilder;
25
26
    /**
27
     * @var array
28
     */
29
    private $filtersConfiguration;
30
31
    /**
32
     * @param StackBuilderInterface $filterSetBuilder
33
     * @param array                 $filtersConfiguration
34
     */
35
    public function __construct(StackBuilderInterface $filterSetBuilder, array $filtersConfiguration = [])
36
    {
37
        $this->filterSetBuilder = $filterSetBuilder;
38
        $this->filtersConfiguration = $filtersConfiguration;
39
    }
40
41
    /**
42
     * @return StackInterface[]
43
     */
44
    public function getFilterSets()
45
    {
46
        if (!empty($this->filterSets)) {
47
            return $this->filterSets;
48
        }
49
50
        foreach ($this->filtersConfiguration as $filterSetName => $filterSetData) {
51
            $this->filterSets[] = $this->filterSetBuilder->build($filterSetName, $filterSetData);
52
        }
53
54
        return $this->filterSets;
55
    }
56
}
57