Conditions | 15 |
Paths | 15 |
Total Lines | 47 |
Code Lines | 30 |
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 |
||
109 | private function getFunction($data) |
||
110 | { |
||
111 | if (isset($data[MmexFunctions::CheckApiVersion])) { |
||
112 | return MmexFunctions::CheckApiVersion; |
||
113 | } |
||
114 | if (isset($data[MmexFunctions::CheckGuid])) { |
||
115 | return MmexFunctions::CheckGuid; |
||
116 | } |
||
117 | if (isset($data[MmexFunctions::DeleteAttachment])) { |
||
118 | return MmexFunctions::DeleteAttachment; |
||
119 | } |
||
120 | if (isset($data[MmexFunctions::DeleteBankAccounts])) { |
||
121 | return MmexFunctions::DeleteBankAccounts; |
||
122 | } |
||
123 | if (isset($data[MmexFunctions::DeleteCategories])) { |
||
124 | return MmexFunctions::DeleteCategories; |
||
125 | } |
||
126 | if (isset($data[MmexFunctions::DeletePayees])) { |
||
127 | return MmexFunctions::DeletePayees; |
||
128 | } |
||
129 | if (isset($data[MmexFunctions::DeleteTransactions])) { |
||
130 | return MmexFunctions::DeleteTransactions; |
||
131 | } |
||
132 | if (isset($data[MmexFunctions::DonwloadAttachment])) { |
||
133 | return MmexFunctions::DonwloadAttachment; |
||
134 | } |
||
135 | if (isset($data[MmexFunctions::DownloadTransactions])) { |
||
136 | return MmexFunctions::DownloadTransactions; |
||
137 | } |
||
138 | if (isset($data[MmexFunctions::ImportBankAccounts])) { |
||
139 | return MmexFunctions::ImportBankAccounts; |
||
140 | } |
||
141 | if (isset($data[MmexFunctions::ImportBankAccounts])) { |
||
142 | return MmexFunctions::ImportBankAccounts; |
||
143 | } |
||
144 | if (isset($data[MmexFunctions::ImportPayees])) { |
||
145 | return MmexFunctions::ImportPayees; |
||
146 | } |
||
147 | if (isset($data[MmexFunctions::DeleteCategories])) { |
||
148 | return MmexFunctions::DeleteCategories; |
||
149 | } |
||
150 | if (isset($data[MmexFunctions::ImportCategories])) { |
||
151 | return MmexFunctions::ImportCategories; |
||
152 | } |
||
153 | |||
154 | throw new \Exception('No valid function request!'); |
||
155 | } |
||
156 | |||
168 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.