| Conditions | 10 |
| Paths | 11 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 92 | public static function processCallback (): bool|int { |
||
| 93 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
||
| 94 | $response = $_POST; |
||
| 95 | } |
||
| 96 | elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { |
||
| 97 | $response = $_GET; |
||
| 98 | } |
||
| 99 | else { |
||
| 100 | return false; |
||
| 101 | } |
||
| 102 | |||
| 103 | if (empty($response['status']) || empty($response['id']) || empty($response['track_id']) || empty($response['order_id'])) { |
||
| 104 | return false; |
||
| 105 | } |
||
| 106 | if ($response['status'] != 10) { |
||
| 107 | return $response['status']; |
||
| 108 | } |
||
| 109 | |||
| 110 | $detail = self::paymentDetail($response['id'], $response['order_id']); |
||
| 111 | if (!isset($detail->status)) { |
||
| 112 | return false; |
||
| 113 | } |
||
| 114 | if ($detail->status != 10) { |
||
| 115 | return $detail->status; |
||
| 116 | } |
||
| 117 | |||
| 118 | return self::paymentConfirm($response['id'], $response['order_id'])->status; |
||
| 119 | } |
||
| 120 | } |