Completed
Push — refonte ( 4dd7b9...524e34 )
by Arnaud
12:58 queued 04:27
created

FilterEvent::addFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace LAG\AdminBundle\Event\Events;
4
5
use LAG\AdminBundle\Event\AbstractEvent;
6
use LAG\AdminBundle\Exception\Exception;
7
use LAG\AdminBundle\Filter\FilterInterface;
8
use Symfony\Component\Form\FormInterface;
9
10
class FilterEvent extends AbstractEvent
11
{
12
    /**
13
     * @var FilterInterface[]
14
     */
15
    private $filters = [];
16
17
    /**
18
     * @var FormInterface[]
19
     */
20
    private $forms = [];
21
22
    /**
23
     * @param FormInterface $form
24
     * @param string        $identifier
25
     *
26
     * @throws Exception
27
     */
28 View Code Duplication
    public function addForm(FormInterface $form, string $identifier)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        if (array_key_exists($identifier, $this->forms)) {
31
            throw new Exception('A form with the identifier "'.$identifier.'" was already added');
32
        }
33
        $this->forms[$identifier] = $form;
34
    }
35
36
    /**
37
     * @return FormInterface[]
38
     */
39
    public function getForms()
40
    {
41
        return $this->forms;
42
    }
43
44
    /**
45
     * Add a filter and its value.
46
     *
47
     * @param FilterInterface $filter
48
     */
49
    public function addFilter(FilterInterface $filter): void
50
    {
51
        $this->filters[] = $filter;
52
    }
53
54
    /**
55
     * @return FilterInterface[]
56
     */
57
    public function getFilters(): array
58
    {
59
        return $this->filters;
60
    }
61
}
62