Completed
Push — develop ( b92fd0...28494b )
by
unknown
12:01
created

InvoiceAddress   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 36 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 3
dl 18
loc 50
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setEventManager() 0 6 1
A getEventManager() 0 8 2
A setParam() 9 9 1
A isValid() 9 9 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
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Orders\Form;
12
13
use Core\Form\Event\FormEvent;
14
use Core\Form\Form;
15
use Core\Form\SummaryForm;
16
use Orders\Entity\InvoiceAddressInterface;
17
use Zend\EventManager\EventManagerInterface;
18
19
/**
20
 * ${CARET}
21
 * 
22
 * @author Mathias Gelhausen <[email protected]>
23
 * @todo write test 
24
 */
25
class InvoiceAddress extends SummaryForm
26
{
27
    protected $baseFieldset = 'Orders/InvoiceAddressFieldset';
28
29
    /**
30
     * The event manager
31
     *
32
     * @var EventManagerInterface
33
     */
34
    protected $events;
35
36
    public function setEventManager(EventManagerInterface $events)
37
    {
38
        $this->events = $events;
39
40
        return $this;
41
    }
42
43
    public function getEventManager()
44
    {
45
        if (!$this->events) {
46
            $this->setEventManager(new \Zend\EventManager\EventManager());
47
        }
48
49
        return $this->events;
50
    }
51
52 View Code Duplication
    public function setParam($key, $value)
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...
53
    {
54
        parent::setParam($key, $value);
55
56
        $events  = $this->getEventManager();
57
        $events->trigger(FormEvent::EVENT_SET_PARAM, $this, [ 'param_name' => $key, 'param_value' => $value ]);
58
59
        return $this;
60
    }
61
62
63 View Code Duplication
    public function isValid()
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...
64
    {
65
        $valid = parent::isValid();
66
67
        $events = $this->getEventManager();
68
        $events->trigger(FormEvent::EVENT_VALIDATE, $this, [ 'isValid' => $valid ]);
69
70
        return $valid;
71
    }
72
73
74
}