| Conditions | 9 |
| Paths | 859 |
| Total Lines | 51 |
| Code Lines | 38 |
| 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 |
||
| 137 | public function getSales(\DateTime $dateFrom, \DateTime $dateTo, array $arrMerchantID = array()) : array |
||
| 138 | { |
||
| 139 | $arrResult = array(); |
||
| 140 | try { |
||
| 141 | $transactionList = $this->_network->getTransactionList($arrMerchantID, $dateFrom, $dateTo); |
||
| 142 | |||
| 143 | foreach($transactionList as $transaction) { |
||
| 144 | |||
| 145 | $myTransaction = Transaction::createInstance(); |
||
| 146 | try { |
||
| 147 | $myTransaction->merchant_ID = $transaction['merchantId']; |
||
| 148 | $myTransaction->title =''; |
||
| 149 | $myTransaction->currency = $transaction['currency']; |
||
| 150 | if (!empty($transaction['date'])) { |
||
| 151 | $date = new \DateTime($transaction['date']); |
||
| 152 | $myTransaction->date = $date; // $date->format('Y-m-d H:i:s'); |
||
| 153 | } |
||
| 154 | if (!empty($transaction['last_updated'])) { |
||
| 155 | $date = new \DateTime($transaction['last_updated']); |
||
| 156 | $myTransaction->update_date = $date; // $date->format('Y-m-d H:i:s'); |
||
| 157 | } |
||
| 158 | if (!empty($transaction['click_date'])){ |
||
| 159 | $date = new \DateTime($transaction['click_date']); |
||
| 160 | $myTransaction->click_date = $date; // $date->format('Y-m-d H:i:s'); |
||
| 161 | } |
||
| 162 | $myTransaction->unique_ID = $transaction['unique_id']; |
||
| 163 | $myTransaction->custom_ID = array_key_exists('custom_id', $transaction) ? $transaction['custom_id'] : ''; |
||
| 164 | $myTransaction->status = $transaction['status']; |
||
| 165 | $myTransaction->amount = $transaction['amount']; |
||
| 166 | $myTransaction->commission = $transaction['commission']; |
||
| 167 | $myTransaction->approved = false; |
||
| 168 | if ($transaction['status'] == \Oara\Utilities::STATUS_CONFIRMED){ |
||
| 169 | $myTransaction->approved = true; |
||
| 170 | } |
||
| 171 | $account_id = $transaction['publisher_id']; |
||
| 172 | $id_site = $transaction['publisher_domain_id']; |
||
| 173 | |||
| 174 | $arrResult[] = $myTransaction; |
||
| 175 | } catch (\Exception $e) { |
||
| 176 | echo "<br><br>errore transazione Skimlinks, id: ".$myTransaction->unique_ID." msg: ".$e->getMessage()."<br><br>"; |
||
| 177 | var_dump($e->getTraceAsString()); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | } catch (\Exception $e) { |
||
| 181 | echo "<br><br>errore generico transazione Skimlinks: ".$e->getMessage()."<br><br>"; |
||
| 182 | var_dump($e->getTraceAsString()); |
||
| 183 | throw new \Exception($e); |
||
| 184 | } |
||
| 185 | |||
| 186 | return $arrResult; |
||
| 187 | } |
||
| 188 | |||
| 219 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.