Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
19 | public function __construct(DIInterface $di) |
||
20 | { |
||
21 | parent::__construct($di); |
||
22 | $this->form->create( |
||
23 | [ |
||
24 | "id" => __CLASS__, |
||
25 | "br-after-label" => false, |
||
26 | "use_fieldset" => false, |
||
27 | "class" => "login-widget", |
||
28 | ], |
||
29 | [ |
||
30 | "name" => [ |
||
31 | "type" => "text", |
||
32 | "validation" => ["not_empty"], |
||
33 | "placeholder" => "name", |
||
34 | "label" => false, |
||
35 | ], |
||
36 | |||
37 | "email" => [ |
||
38 | "type" => "text", |
||
39 | "placeholder" => "email", |
||
40 | "label" => false, |
||
41 | ], |
||
42 | "question" => [ |
||
43 | "type" => "text", |
||
44 | "placeholder" => "Din favoriträtt", |
||
45 | "validation" => ["not_empty"], |
||
46 | "label" => false, |
||
47 | ], |
||
48 | |||
49 | "password" => [ |
||
50 | "type" => "password", |
||
51 | "validation" => ["not_empty"], |
||
52 | "placeholder" => "password", |
||
53 | "label" => false |
||
54 | ], |
||
55 | |||
56 | "password-again" => [ |
||
57 | "type" => "password", |
||
58 | "validation" => [ |
||
59 | "match" => "password" |
||
60 | ], |
||
61 | "placeholder" => "password", |
||
62 | "label" => false |
||
63 | ], |
||
64 | |||
65 | "submit" => [ |
||
66 | "label" => false, |
||
67 | "type" => "submit", |
||
68 | "value" => "Create user", |
||
69 | "callback" => [$this, "callbackSubmit"] |
||
70 | ], |
||
71 | ] |
||
72 | ); |
||
73 | } |
||
74 | |||
122 |