| Conditions | 12 |
| Paths | 3 |
| Total Lines | 49 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 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 |
||
| 10 | public function index() { |
||
|
|
|||
| 11 | $renderer = DebugView::create(); |
||
| 12 | $renderer->writeHeader(); |
||
| 13 | $renderer->writeInfo("Installed Omnipay Payment Gateways", Director::absoluteBaseURL()); |
||
| 14 | $types = $this->PaymentTypes(); |
||
| 15 | |||
| 16 | echo "<table style=\"font-size:12px;\" border=1 cellspacing=0> |
||
| 17 | <thead> |
||
| 18 | <tr> |
||
| 19 | <td>Short Name</td> |
||
| 20 | <td>Full name</td> |
||
| 21 | <td>Purchase</td> |
||
| 22 | <td>Authorize</td> |
||
| 23 | <td>CompleteAuthorize</td> |
||
| 24 | <td>Capture</td> |
||
| 25 | <td>Complete Purchase</td> |
||
| 26 | <td>Refund</td> |
||
| 27 | <td>Void</td> |
||
| 28 | <td>Create Card</td> |
||
| 29 | <td>Delete Card</td> |
||
| 30 | <td>Update Card</td> |
||
| 31 | </tr> |
||
| 32 | </thead> |
||
| 33 | <tbody>"; |
||
| 34 | |||
| 35 | foreach ($types as $gateway) { |
||
| 36 | echo "<tr>". |
||
| 37 | "<td>".$gateway->getShortName()."</td>". |
||
| 38 | "<td>".$gateway->getName()."</td>". |
||
| 39 | "<td>yes</td>". //purchase is always supported |
||
| 40 | "<td>".($gateway->supportsAuthorize() ? "yes" : "")."</td>". |
||
| 41 | "<td>".($gateway->supportsCompleteAuthorize() ? "yes" : "")."</td>". |
||
| 42 | "<td>".($gateway->supportsCapture() ? "yes" : "")."</td>". |
||
| 43 | "<td>".($gateway->supportsCompletePurchase() ? "yes" : "")."</td>". |
||
| 44 | "<td>".($gateway->supportsRefund() ? "yes" : "")."</td>". |
||
| 45 | "<td>".($gateway->supportsVoid() ? "yes" : "")."</td>". |
||
| 46 | "<td>".($gateway->supportsCreateCard() ? "yes" : "")."</td>". |
||
| 47 | "<td>".($gateway->supportsDeleteCard() ? "yes" : "")."</td>". |
||
| 48 | "<td>".($gateway->supportsUpdateCard() ? "yes" : "")."</td>". |
||
| 49 | "</tr>"; |
||
| 50 | if ($this->request->getVar('defaults')) { |
||
| 51 | echo "<tr><td colspan=\"11\">"; |
||
| 52 | var_dump($gateway->getDefaultParameters()); |
||
| 53 | echo "</td></tr>"; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | echo "</tbody></table>"; |
||
| 57 | $renderer->writeFooter(); |
||
| 58 | } |
||
| 59 | |||
| 73 |
A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.
You can also find more information in the “Code” section of your repository.