Base::__construct()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 80
rs 8.8387
cc 1
eloc 46
nc 1
nop 0

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