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

AclroleForm::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 67

Duplication

Lines 67
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 67
loc 67
ccs 0
cts 14
cp 0
rs 8.72
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 View Code Duplication
class AclroleForm extends Form
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    public function __construct($name = null)
23
    {
24
        // we want to ignore the name passed
25
        parent::__construct('aclrole');
26
        $this->setAttribute('method', 'post');
27
        
28
        $this->add(
29
            array(
30
            'name' => 'aclroles_id',
31
            'attributes' => array(
32
            'type'  => 'hidden' ,
33
            ),
34
            )
35
        );
36
        $this->add(
37
            array(
38
            'name' => 'roleslug',
39
            'type' => 'text',
40
            'attributes' => array(
41
            'type'  => 'text',
42
            ),
43
            'options' => array(
44
            'label' => 'role slug',
45
            ),
46
            )
47
        );
48
        $this->add(
49
            array(
50
            'name' => 'rolename',
51
            'type' => 'text',
52
            'attributes' => array(
53
            'type'  => 'text',
54
            ),
55
            'options' => array(
56
            'label' => 'role name',
57
            ),
58
            )
59
        );
60
61
        $this->add(
62
            array(
63
            'name' => 'submit',
64
            'attributes' => array(
65
            'type'  => 'submit',
66
            'value' => 'save',
67
            'id' => 'submitbutton',
68
            ),
69
            'options' => array(
70
            'label' => 'save',
71
            ),
72
            )
73
        );
74
75
        $this->add(
76
            array(
77
            'name' => 'reset',
78
            'attributes' => array(
79
                   'type'  => 'reset',
80
                  'value' => 'reset',
81
                  'id' => 'resetbutton',
82
               ),
83
            'options' => array(
84
            'label' => 'reset',
85
            ),
86
            )
87
        );
88
    }
89
}