Conditions | 23 |
Paths | 23 |
Total Lines | 50 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
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 |
||
96 | private function actionMapper(int $moduleId) |
||
97 | { |
||
98 | switch ($moduleId) { |
||
99 | case 1: |
||
100 | return ActionsInterface::ACCOUNT_SEARCH; |
||
101 | case 100: |
||
102 | return ActionsInterface::ACCOUNT_VIEW; |
||
103 | case 104: |
||
104 | return ActionsInterface::ACCOUNT_VIEW_PASS; |
||
105 | case 103: |
||
106 | return ActionsInterface::ACCOUNT_DELETE; |
||
107 | case 101: |
||
108 | return ActionsInterface::ACCOUNT_CREATE; |
||
109 | case 615: |
||
110 | return ActionsInterface::CATEGORY_SEARCH; |
||
111 | case 610: |
||
112 | return ActionsInterface::CATEGORY_VIEW; |
||
113 | case 611: |
||
114 | return ActionsInterface::CATEGORY_CREATE; |
||
115 | case 612: |
||
116 | return ActionsInterface::CATEGORY_EDIT; |
||
117 | case 613: |
||
118 | return ActionsInterface::CATEGORY_DELETE; |
||
119 | case 625: |
||
120 | return ActionsInterface::CLIENT_SEARCH; |
||
121 | case 620: |
||
122 | return ActionsInterface::CLIENT_VIEW; |
||
123 | case 621: |
||
124 | return ActionsInterface::CLIENT_CREATE; |
||
125 | case 622: |
||
126 | return ActionsInterface::CLIENT_EDIT; |
||
127 | case 623: |
||
128 | return ActionsInterface::CLIENT_DELETE; |
||
129 | case 685: |
||
130 | return ActionsInterface::TAG_SEARCH; |
||
131 | case 681: |
||
132 | return ActionsInterface::TAG_VIEW; |
||
133 | case 680: |
||
134 | return ActionsInterface::TAG_CREATE; |
||
135 | case 682: |
||
136 | return ActionsInterface::TAG_EDIT; |
||
137 | case 683: |
||
138 | return ActionsInterface::TAG_DELETE; |
||
139 | case 1041: |
||
140 | return ActionsInterface::CONFIG_BACKUP_RUN; |
||
141 | case 1061: |
||
142 | return ActionsInterface::CONFIG_EXPORT_RUN; |
||
143 | } |
||
144 | |||
145 | return $moduleId; |
||
146 | } |
||
152 | } |