Passed
Push — v2 ( e7f8e2...a41bff )
by Daniel
04:01
created

ImagineMetadata::setFilters()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\Dto\File;
15
16
use Doctrine\Common\Collections\ArrayCollection;
17
18
/**
19
 * @author Daniel West <[email protected]>
20
 */
21
class ImagineMetadata
22
{
23
    private ArrayCollection $filters;
24
25
    public function __construct()
26
    {
27
        $this->filters = new ArrayCollection();
28
    }
29
30
    public function addFilter(string $key, ImageMetadata $imageMetadata): self
31
    {
32
        $this->filters->set($key, $imageMetadata);
33
34
        return $this;
35
    }
36
37
    public function removeFilter(string $key): self
38
    {
39
        $this->filters->remove($key);
40
41
        return $this;
42
    }
43
44
    public function setFilters(array $filters)
45
    {
46
        $this->filters = new ArrayCollection();
47
        foreach ($filters as $key => $filter) {
48
            $this->addFilter($key, $filter);
49
        }
50
    }
51
52
    public function getFilters()
53
    {
54
        return $this->filters;
55
    }
56
}
57