Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 29 |
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 |
||
24 | protected function defineFieldDefinitions(): void |
||
25 | { |
||
26 | // add dynamic rules at $this->processFieldDefinitions() |
||
27 | $this->fieldDefinitions = [ |
||
28 | 'id' => $this->getIdField(), |
||
29 | |||
30 | 'username' => $this->getField( |
||
31 | __('username'), |
||
32 | [ |
||
33 | 'rules' => [ |
||
34 | 'required', |
||
35 | ['lengthMin', 3] |
||
36 | ], |
||
37 | 'display_in_list' => true |
||
38 | ] |
||
39 | ), |
||
40 | |||
41 | 'password' => $this->getField( |
||
42 | __('password'), |
||
43 | [ |
||
44 | 'type' => 'password', |
||
45 | 'rules' => [ |
||
46 | 'required', |
||
47 | ['lengthMin', 8] |
||
48 | ], |
||
49 | 'filter' => FILTER_UNSAFE_RAW, |
||
50 | ] |
||
51 | ), |
||
52 | |||
53 | 'role' => $this->getField( |
||
54 | __('role'), |
||
55 | [ |
||
56 | 'type' => 'select', |
||
57 | 'options' => [ |
||
58 | 'editor' => __('editor'), |
||
59 | 'admin' => __('admin'), |
||
60 | ], |
||
61 | 'rules' => [ |
||
62 | 'required', |
||
63 | ], |
||
64 | 'attributes' => [ |
||
65 | 'class' => 'form-control form-select' |
||
66 | ], |
||
67 | 'display_in_list' => true |
||
68 | ] |
||
69 | ), |
||
70 | |||
71 | 'created_at' => $this->getReadOnlyField( |
||
72 | __('created_at', 'Created'), |
||
73 | [ |
||
74 | 'display_in_list' => true |
||
75 | ] |
||
180 |