| Conditions | 1 |
| Paths | 1 |
| Total Lines | 139 |
| Code Lines | 88 |
| 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 |
||
| 45 | public function providerProcess(): array |
||
| 46 | { |
||
| 47 | return [ |
||
| 48 | 'normal' => [ |
||
| 49 | [ |
||
| 50 | 'uppTransactionId' => '123456789012345678', |
||
| 51 | 'status' => 'success', |
||
| 52 | 'refno' => '1007', |
||
| 53 | 'amount' => '10000', |
||
| 54 | 'currency' => 'CHF', |
||
| 55 | 'responseMessage' => 'Payment was successful', |
||
| 56 | ], |
||
| 57 | '100.00', |
||
| 58 | [ |
||
| 59 | 'message' => [ |
||
| 60 | 'status' => 'success', |
||
| 61 | 'message' => 'Payment was successful', |
||
| 62 | ], |
||
| 63 | ], |
||
| 64 | ], |
||
| 65 | 'user without account yet' => [ |
||
| 66 | [ |
||
| 67 | 'uppTransactionId' => '123456789012345678', |
||
| 68 | 'status' => 'success', |
||
| 69 | 'refno' => '1008', |
||
| 70 | 'amount' => '10000', |
||
| 71 | 'currency' => 'CHF', |
||
| 72 | 'responseMessage' => 'Payment was successful', |
||
| 73 | ], |
||
| 74 | '100.00', |
||
| 75 | [ |
||
| 76 | 'message' => [ |
||
| 77 | 'status' => 'success', |
||
| 78 | 'message' => 'Payment was successful', |
||
| 79 | ], |
||
| 80 | ], |
||
| 81 | ], |
||
| 82 | 'error' => [ |
||
| 83 | [ |
||
| 84 | 'uppTransactionId' => '876543210987654321', |
||
| 85 | 'status' => 'error', |
||
| 86 | 'refno' => '1007', |
||
| 87 | 'errorMessage' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
| 88 | ], |
||
| 89 | '0.00', |
||
| 90 | [ |
||
| 91 | 'message' => [ |
||
| 92 | 'status' => 'error', |
||
| 93 | 'message' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
| 94 | ], |
||
| 95 | ], |
||
| 96 | ], |
||
| 97 | 'cancel' => [ |
||
| 98 | [ |
||
| 99 | 'uppTransactionId' => '876543210987654321', |
||
| 100 | 'status' => 'cancel', |
||
| 101 | 'refno' => '1007', |
||
| 102 | ], |
||
| 103 | '0.00', |
||
| 104 | [ |
||
| 105 | 'message' => [ |
||
| 106 | 'status' => 'cancel', |
||
| 107 | 'message' => 'Cancelled', |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | ], |
||
| 111 | 'invalid body' => [ |
||
| 112 | null, |
||
| 113 | '0.00', |
||
| 114 | [ |
||
| 115 | 'message' => [ |
||
| 116 | 'status' => 'error', |
||
| 117 | 'message' => 'Parsed body is expected to be an array but got: NULL', |
||
| 118 | ], |
||
| 119 | ], |
||
| 120 | ], |
||
| 121 | 'invalid status' => [ |
||
| 122 | [ |
||
| 123 | 'uppTransactionId' => '123456789012345678', |
||
| 124 | 'status' => 'non-existing-status', |
||
| 125 | 'refno' => '1007', |
||
| 126 | 'amount' => '10000', |
||
| 127 | 'currency' => 'CHF', |
||
| 128 | 'responseMessage' => 'Payment was successful', |
||
| 129 | ], |
||
| 130 | '0.00', |
||
| 131 | [ |
||
| 132 | 'message' => [ |
||
| 133 | 'status' => 'error', |
||
| 134 | 'message' => 'Unsupported status in Datatrans data: non-existing-status', |
||
| 135 | ], |
||
| 136 | ], |
||
| 137 | ], |
||
| 138 | 'non-existing user' => [ |
||
| 139 | [ |
||
| 140 | 'uppTransactionId' => '123456789012345678', |
||
| 141 | 'status' => 'success', |
||
| 142 | 'amount' => '10000', |
||
| 143 | 'currency' => 'CHF', |
||
| 144 | 'responseMessage' => 'Payment was successful', |
||
| 145 | ], |
||
| 146 | '0.00', |
||
| 147 | [ |
||
| 148 | 'message' => [ |
||
| 149 | 'status' => 'error', |
||
| 150 | 'message' => 'Cannot create transactions without a user', |
||
| 151 | ], |
||
| 152 | ], |
||
| 153 | ], |
||
| 154 | 'non-existing amount' => [ |
||
| 155 | [ |
||
| 156 | 'uppTransactionId' => '123456789012345678', |
||
| 157 | 'status' => 'success', |
||
| 158 | 'refno' => '1007', |
||
| 159 | 'currency' => 'CHF', |
||
| 160 | 'responseMessage' => 'Payment was successful', |
||
| 161 | ], |
||
| 162 | '0.00', |
||
| 163 | [ |
||
| 164 | 'message' => [ |
||
| 165 | 'status' => 'error', |
||
| 166 | 'message' => 'Cannot create transactions without an amount', |
||
| 167 | ], |
||
| 168 | ], |
||
| 169 | ], |
||
| 170 | 'invalid currency' => [ |
||
| 171 | [ |
||
| 172 | 'uppTransactionId' => '123456789012345678', |
||
| 173 | 'status' => 'success', |
||
| 174 | 'refno' => '1007', |
||
| 175 | 'amount' => '10000', |
||
| 176 | 'currency' => 'USD', |
||
| 177 | 'responseMessage' => 'Payment was successful', |
||
| 178 | ], |
||
| 179 | '0.00', |
||
| 180 | [ |
||
| 181 | 'message' => [ |
||
| 182 | 'status' => 'error', |
||
| 183 | 'message' => 'Can only create transactions for CHF, but got: USD', |
||
| 184 | ], |
||
| 190 |