Base::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 97

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 97
rs 8.0654
c 0
b 0
f 0
cc 1
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace LmcUser\Form;
4
5
use Laminas\Form\Element;
6
7
class Base extends ProvidesEventsForm
8
{
9
    public function __construct($name = null)
10
    {
11
        parent::__construct($name);
12
13
        $this->add(
14
            array(
15
            'name' => 'username',
16
            'options' => array(
17
                'label' => 'Username',
18
            ),
19
            'attributes' => array(
20
                'type' => 'text'
21
            ),
22
            )
23
        );
24
25
        $this->add(
26
            array(
27
            'name' => 'email',
28
            'options' => array(
29
                'label' => 'Email',
30
            ),
31
            'attributes' => array(
32
                'type' => 'text'
33
            ),
34
            )
35
        );
36
37
        $this->add(
38
            array(
39
            'name' => 'display_name',
40
            'options' => array(
41
                'label' => 'Display Name',
42
            ),
43
            'attributes' => array(
44
                'type' => 'text'
45
            ),
46
            )
47
        );
48
49
        $this->add(
50
            array(
51
            'name' => 'password',
52
            'type' => 'password',
53
            'options' => array(
54
                'label' => 'Password',
55
            ),
56
            'attributes' => array(
57
                'type' => 'password'
58
            ),
59
            )
60
        );
61
62
        $this->add(
63
            array(
64
            'name' => 'passwordVerify',
65
            'type' => 'password',
66
            'options' => array(
67
                'label' => 'Password Verify',
68
            ),
69
            'attributes' => array(
70
                'type' => 'password'
71
            ),
72
            )
73
        );
74
75
        $submitElement = new Element\Button('submit');
76
        $submitElement
77
            ->setLabel('Submit')
78
            ->setAttributes(
79
                array(
80
                'type'  => 'submit',
81
                )
82
            );
83
84
        $this->add(
85
            $submitElement,
86
            array(
87
            'priority' => -100,
88
            )
89
        );
90
91
        $this->add(
92
            array(
93
            'name' => 'userId',
94
            'type' => 'Laminas\Form\Element\Hidden',
95
            'attributes' => array(
96
                'type' => 'hidden'
97
            ),
98
            )
99
        );
100
101
        // @TODO: Fix this... getValidator() is a protected method.
102
        //$csrf = new Element\Csrf('csrf');
103
        //$csrf->getValidator()->setTimeout($this->getRegistrationOptions()->getUserFormTimeout());
104
        //$this->add($csrf);
105
    }
106
107
    public function init()
108
    {
109
    }
110
}
111