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

AclmatrixForm::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 72

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 72
ccs 0
cts 16
cp 0
rs 8.6109
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 AclmatrixForm 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
            'attributes' => array(
40
            'type'  => 'hidden',
41
            ),
42
            )
43
        );
44
        $this->add(
45
            array(
46
            'name' => 'aclresources_id',
47
            'attributes' => array(
48
            'type'  => 'hidden',
49
            ),
50
            )
51
        );
52
        $this->add(
53
            array(
54
            'name' => 'state',
55
            'type' => 'select',
56
            'attributes' => array(
57
            'type'  => 'select',
58
            'options'    => array(
59
                    ''    => '---',
60
                    'allow'    => 'allow',
61
                    'deny'    => 'deny',
62
            ),
63
            ),
64
            )
65
        );
66
67
        $this->add(
68
            array(
69
            'name' => 'reset',
70
            'attributes' => array(
71
            'type'  => 'reset',
72
            'value' => 'reset',
73
            'id' => 'resetbutton',
74
            ),
75
            'options' => array(
76
            'label' => 'reset',
77
            ),
78
            )
79
        );
80
        $this->add(
81
            array(
82
            'name' => 'submit',
83
            'attributes' => array(
84
            'type'  => 'submit',
85
            'value' => 'save',
86
            'id' => 'submitbutton',
87
            ),
88
            'options' => array(
89
            'label' => 'save',
90
            ),
91
            )
92
        );
93
    }
94
}