Completed
Push — refonte ( 2cad75...548acb )
by Arnaud
06:10
created

FormEvent::addForm()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace LAG\AdminBundle\Event\Events;
4
5
use LAG\AdminBundle\Event\AbstractEvent;
6
use LAG\AdminBundle\Exception\Exception;
7
use Symfony\Component\Form\FormInterface;
8
9
class FormEvent extends AbstractEvent
10
{
11
    /**
12
     * @var FormInterface[]
13
     */
14
    private $forms = [];
15
16
    /**
17
     * @param FormInterface $form
18
     * @param string        $identifier
19
     *
20
     * @throws Exception
21
     */
22 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...
23
    {
24
        if (array_key_exists($identifier, $this->forms)) {
25
            throw new Exception('A form with the identifier "'.$identifier.'" was already added');
26
        }
27
        $this->forms[$identifier] = $form;
28
    }
29
30
    /**
31
     * @return FormInterface[]
32
     */
33
    public function getForms()
34
    {
35
        return $this->forms;
36
    }
37
}
38