Passed
Push — master ( 700b0f...aafb0a )
by Björn
18:25 queued 10s
created

AclForm::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 87

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 87
ccs 0
cts 16
cp 0
rs 8.2836
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2

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
20
class AclForm extends Form
21
{
22
    public function __construct($name = null)
23
    {
24
        // we want to ignore the name passed
25
        parent::__construct('acl');
26
        $this->setAttribute('method', 'post');
27
        
28
        $this->add(
29
            array(
30
            'name' => 'acl_id',
31
            'attributes' => array(
32
            'type'  => 'hidden',
33
            ),
34
            )
35
        );
36
        $this->add(
37
            array(
38
            'name' => 'aclroles_id',
39
            'type' => 'select',
40
            'attributes' => array(
41
            'type'  => 'select',
42
            'options'    => array(
43
            ),
44
            ),
45
            'options' => array(
46
            'label' => 'role',
47
            ),
48
            )
49
        );
50
        $this->add(
51
            array(
52
            'name' => 'aclresources_id',
53
            'type' => 'select',
54
            'attributes' => array(
55
            'type'  => 'select',
56
            'options'    => array(
57
            ),
58
            ),
59
            'options' => array(
60
            'label' => 'resource',
61
            ),
62
            )
63
        );
64
        $this->add(
65
            array(
66
            'name' => 'state',
67
            'type' => 'select',
68
            'attributes' => array(
69
            'type'  => 'select',
70
            'options'    => array(
71
                    ''    => '---',
72
                    'allow'    => 'allow',
73
                    'deny'    => 'deny',
74
            ),
75
            ),
76
            'options' => array(
77
            'label' => 'state',
78
            ),
79
            )
80
        );
81
82
        $this->add(
83
            array(
84
            'name' => 'reset',
85
            'attributes' => array(
86
            'type'  => 'reset',
87
            'value' => 'reset',
88
            'id' => 'resetbutton',
89
            ),
90
            'options' => array(
91
            'label' => 'reset',
92
            ),
93
            )
94
        );
95
        $this->add(
96
            array(
97
            'name' => 'submit',
98
            'attributes' => array(
99
            'type'  => 'submit',
100
            'value' => 'save',
101
            'id' => 'submitbutton',
102
            ),
103
            'options' => array(
104
            'label' => 'save',
105
            ),
106
            )
107
        );
108
    }
109
}