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

FormEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 24.14 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 7
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addForm() 7 7 2
A getForms() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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