Conditions | 1 |
Paths | 1 |
Total Lines | 115 |
Code Lines | 74 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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(); |
||
|
|||
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 | ), |
||
142 | } |