Passed
Branch ops-updates (277b44)
by Björn
05:09
created

ApplicationsForm::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 115
Code Lines 74

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 74
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 115
ccs 0
cts 23
cp 0
crap 2
rs 8.5672

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
 * BB's Zend Framework 2 Components
4
 * 
5
 * AdminModule
6
 *
7
 * @package   [MyApplication]
8
 * @package   BB's Zend Framework 2 Components
9
 * @package   AdminModule
10
 * @author    Björn Bartels <[email protected]>
11
 * @link      https://gitlab.bjoernbartels.earth/groups/zf2
12
 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
13
 * @copyright copyright (c) 2016 Björn Bartels <[email protected]>
14
 */
15
16
namespace Admin\Form;
17
18
use Zend\Form\Form;
19
use Admin\Module;
20
21
class ApplicationsForm extends Form
22
{
23
    public function __construct($name = null)
24
    {
25
        
26
        // we want to ignore the name passed
27
        parent::__construct('applications');
28
        $oModule = new Module();
29
        $cfg = $oModule->getConfig();
0 ignored issues
show
Unused Code introduced by
The assignment to $cfg is dead and can be removed.
Loading history...
30
        
31
        $this->setAttribute('method', 'post');
32
        $this->add(
33
            array(
34
            'name' => 'application_id',
35
            'attributes' => array(
36
            'type'  => 'hidden',
37
            ),
38
            )
39
        );
40
        $this->add(
41
            array(
42
            'name' => 'name',
43
            'attributes' => array(
44
            'type'  => 'text',
45
            ),
46
            'options' => array(
47
            'label' => 'name',
48
            ),
49
            )
50
        );
51
        $this->add(
52
            array(
53
            'name' => 'shortname',
54
            'attributes' => array(
55
            'type'  => 'text',
56
            ),
57
            'options' => array(
58
            'label' => 'shortname',
59
            ),
60
            )
61
        );
62
        $this->add(
63
            array(
64
            'name' => 'path',
65
            'type'  => 'text',
66
            'attributes' => array(
67
            'type'  => 'text',
68
            ),
69
            'options' => array(
70
            'label' => 'path',
71
            ),
72
            )
73
        );
74
        $this->add(
75
            array(
76
            'name' => 'url',
77
            'type'  => 'url',
78
            'attributes' => array(
79
            'type'  => 'url',
80
            ),
81
            'options' => array(
82
            'label' => 'url',
83
            ),
84
            )
85
        );
86
        $this->add(
87
            array(
88
            'name' => 'email',
89
            'type'  => 'email',
90
            'attributes' => array(
91
            'type'  => 'email',
92
            ),
93
            'options' => array(
94
            'label' => 'admin email',
95
            ),
96
            )
97
        );
98
99
        $this->add(
100
            array(
101
            'name' => 'client_id',
102
            'type'  => 'select',
103
            'attributes' => array(
104
                    'type'  => 'select',
105
                    'options' => array(),
106
            ),
107
            'options' => array(
108
            'label' => 'client',
109
            ),
110
            )
111
        );
112
        
113
        
114
        $this->add(
115
            array(
116
            'name' => 'submit',
117
            'attributes' => array(
118
            'type'  => 'submit',
119
            'value' => 'save',
120
            'id' => 'submitbutton',
121
            ),
122
            'options' => array(
123
            'label' => 'save',
124
            ),
125
            )
126
        );
127
        
128
        $this->add(
129
            array(
130
            'name' => 'reset',
131
            'attributes' => array(
132
            'type'  => 'reset',
133
            'value' => 'reset',
134
            'id' => 'resetbutton',
135
            ),
136
            'options' => array(
137
            'label' => 'reset',
138
            ),
139
            )
140
        );
141
    }
142
}