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

AclresourceForm::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 66

Duplication

Lines 66
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 66
loc 66
ccs 0
cts 14
cp 0
rs 8.7418
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 AclresourceForm 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('aclresource');
26
        $this->setAttribute('method', 'post');
27
        
28
        $this->add(
29
            array(
30
            'name' => 'aclresources_id',
31
            'attributes' => array(
32
            'type'  => 'hidden',
33
            ),
34
            )
35
        );
36
        $this->add(
37
            array(
38
            'name' => 'resourceslug',
39
            'type' => 'text',
40
            'attributes' => array(
41
            'type'  => 'text',
42
            ),
43
            'options' => array(
44
            'label' => 'resource slug',
45
            ),
46
            )
47
        );
48
        $this->add(
49
            array(
50
            'name' => 'resourcename',
51
            'type' => 'text',
52
            'attributes' => array(
53
            'type'  => 'text',
54
            ),
55
            'options' => array(
56
            'label' => 'resource name',
57
            ),
58
            )
59
        );
60
61
        $this->add(
62
            array(
63
            'name' => 'reset',
64
            'attributes' => array(
65
            'type'  => 'reset',
66
            'value' => 'reset',
67
            'id' => 'resetbutton',
68
            ),
69
            'options' => array(
70
            'label' => 'reset',
71
            ),
72
            )
73
        );
74
        $this->add(
75
            array(
76
            'name' => 'submit',
77
            'attributes' => array(
78
            'type'  => 'submit',
79
            'value' => 'save',
80
            'id' => 'submitbutton',
81
            ),
82
            'options' => array(
83
            'label' => 'save',
84
            ),
85
            )
86
        );
87
    }
88
}