Completed
Pull Request — 2.0 (#1098)
by
unknown
15:14 queued 12:33
created

StackCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
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
    private $stacks = [];
17
18
    /**
19
     * @var StackBuilderInterface
20
     */
21
    private $stackBuilder;
22
23
    /**
24
     * @var array
25
     */
26
    private $filtersConfiguration;
27
28
    public function __construct(StackBuilderInterface $stackBuilder, array $filtersConfiguration = [])
29
    {
30
        $this->stackBuilder = $stackBuilder;
31
        $this->filtersConfiguration = $filtersConfiguration;
32
    }
33
34
    /**
35
     * @return StackInterface[]
36
     */
37
    public function getStacks()
38
    {
39
        if (!empty($this->stacks)) {
40
            return $this->stacks;
41
        }
42
43
        foreach ($this->filtersConfiguration as $filterSetName => $filterSetData) {
44
            $this->stacks[] = $this->stackBuilder->build($filterSetName, $filterSetData);
45
        }
46
47
        return $this->stacks;
48
    }
49
}
50