Conditions | 5 |
Paths | 1 |
Total Lines | 116 |
Code Lines | 56 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
76 | protected function lazy_get_children() |
||
77 | { |
||
78 | $values = $this->values; |
||
79 | $user = $this->user; |
||
80 | $uid = $values[User::UID]; |
||
81 | $languages = $this->app->locale['languages']; |
||
82 | |||
83 | uasort($languages, 'ICanBoogie\unaccent_compare_ci'); |
||
84 | |||
85 | $administer = $user->has_permission(Module::PERMISSION_MANAGE, $this->module); |
||
86 | |||
87 | return array_merge(parent::lazy_get_children(), [ |
||
88 | |||
89 | # |
||
90 | # name group |
||
91 | # |
||
92 | |||
93 | User::FIRSTNAME => new Text([ |
||
94 | |||
95 | Group::LABEL => 'firstname' |
||
96 | |||
97 | ]), |
||
98 | |||
99 | User::LASTNAME => new Text([ |
||
100 | |||
101 | Group::LABEL => 'lastname' |
||
102 | |||
103 | ]), |
||
104 | |||
105 | User::NICKNAME => new Text([ |
||
106 | |||
107 | Group::LABEL => 'Nickname' |
||
108 | |||
109 | ]), |
||
110 | |||
111 | User::USERNAME => $administer ? new Text([ |
||
112 | |||
113 | Group::LABEL => 'username', |
||
114 | Element::REQUIRED => true |
||
115 | |||
116 | ]) : null, |
||
117 | |||
118 | User::NAME_AS => $this->create_control_for_name_as(), |
||
119 | |||
120 | # |
||
121 | # connection group |
||
122 | # |
||
123 | |||
124 | User::EMAIL => new Text([ |
||
125 | |||
126 | Group::LABEL => 'email', |
||
127 | Element::GROUP => 'connection', |
||
128 | Element::REQUIRED => true, |
||
129 | Element::VALIDATION => 'email', |
||
130 | |||
131 | 'autocomplete' => 'off' |
||
132 | |||
133 | ]), |
||
134 | |||
135 | User::PASSWORD => new Text([ |
||
136 | |||
137 | Element::LABEL => 'password', |
||
138 | Element::LABEL_POSITION => 'above', |
||
139 | Element::DESCRIPTION => 'password_' . ($uid ? 'update' : 'new'), |
||
140 | Element::GROUP => 'connection', |
||
141 | |||
142 | 'autocomplete' => 'off', |
||
143 | 'type' => 'password', |
||
144 | 'value' => '' |
||
145 | |||
146 | ]), |
||
147 | |||
148 | User::PASSWORD . '-verify' => new Text([ |
||
149 | |||
150 | Element::LABEL => 'password_confirm', |
||
151 | Element::LABEL_POSITION => 'above', |
||
152 | Element::DESCRIPTION => 'password_confirm', |
||
153 | Element::GROUP => 'connection', |
||
154 | |||
155 | 'autocomplete' => 'off', |
||
156 | 'type' => 'password', |
||
157 | 'value' => '' |
||
158 | |||
159 | ]), |
||
160 | |||
161 | User::IS_ACTIVATED => ($uid == 1 || !$administer) ? null : new Element(Element::TYPE_CHECKBOX, [ |
||
162 | |||
163 | Element::LABEL => 'is_activated', |
||
164 | Element::GROUP => 'connection', |
||
165 | Element::DESCRIPTION => 'is_activated' |
||
166 | |||
167 | ]), |
||
168 | |||
169 | User::ROLES => $this->create_control_for_role(), |
||
170 | |||
171 | User::LANGUAGE => new Element('select', [ |
||
172 | |||
173 | Group::LABEL => 'language', |
||
174 | Element::GROUP => 'advanced', |
||
175 | Element::DESCRIPTION => 'language', |
||
176 | Element::OPTIONS => [ null => '' ] + $languages |
||
177 | |||
178 | ]), |
||
179 | |||
180 | 'timezone' => new Widget\TimeZone([ |
||
181 | |||
182 | Group::LABEL => 'timezone', |
||
183 | Element::GROUP => 'advanced', |
||
184 | Element::DESCRIPTION =>'timezone' |
||
185 | |||
186 | ]), |
||
187 | |||
188 | User::RESTRICTED_SITES => $this->create_control_for_restricted_sites_ids() |
||
189 | |||
190 | ]); |
||
191 | } |
||
192 | |||
346 |
This class constant has been deprecated.