| Conditions | 8 |
| Paths | 96 |
| Total Lines | 55 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 37 | protected function fillCardDetails($analyzeResponse, $domXpath) |
||
| 38 | { |
||
| 39 | $cardNumber = $domXpath->query('//fop:PrimaryAccountNumber'); |
||
| 40 | if ($cardNumber->length > 0) { |
||
| 41 | $analyzeResponse->response->Success->VirtualCard->Card->PrimaryAccountNumber = |
||
| 42 | $cardNumber->item(0)->nodeValue; |
||
| 43 | } |
||
| 44 | |||
| 45 | $cvvNumber = $domXpath->query('//fop:CVV'); |
||
| 46 | if ($cvvNumber->length > 0) { |
||
| 47 | $analyzeResponse->response->Success->VirtualCard->Card->CVV = |
||
| 48 | $cvvNumber->item(0)->nodeValue; |
||
| 49 | } |
||
| 50 | |||
| 51 | $address = $domXpath->query('//fop:AddressVerificationSystemValue'); |
||
| 52 | if ($address->length > 0) { |
||
| 53 | if (empty($analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue)) { |
||
| 54 | $analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue = new stdClass(); |
||
| 55 | } |
||
| 56 | $analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue->Line = |
||
| 57 | $address->item(0)->nodeValue; |
||
| 58 | $analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue->CityName = |
||
| 59 | $address->item(0)->getAttribute('CityName'); |
||
| 60 | $analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue->PostalCode = |
||
| 61 | $address->item(0)->getAttribute('PostalCode'); |
||
| 62 | $analyzeResponse->response->Success->VirtualCard->Card->AddressVerificationSystemValue->Country = |
||
| 63 | $address->item(0)->getAttribute('Country'); |
||
| 64 | } |
||
| 65 | |||
| 66 | $limitations = $domXpath->query('//pay:Limitations'); |
||
| 67 | if ($limitations->length > 0) { |
||
| 68 | $limitationsNodesArrayData = $this->nodeToArray($limitations->item(0)); |
||
| 69 | $analyzeResponse->response->Success->VirtualCard->AllowedTransactions = |
||
| 70 | $limitationsNodesArrayData['pay:AllowedTransactions'][0]['Maximum']; |
||
| 71 | $analyzeResponse->response->Success->VirtualCard->ValidityPeriod = |
||
| 72 | $limitationsNodesArrayData['pay:ValidityPeriod'][0]['EndDate']; |
||
| 73 | } |
||
| 74 | |||
| 75 | $balance = $domXpath->query('//pay:Value[@Type=\'AvailableBalance\']'); |
||
| 76 | |||
| 77 | if ($balance->length === 0) { |
||
| 78 | // OnCard = amount actually on card, but some responses may not contain such type |
||
| 79 | $balance = $domXpath->query('//pay:Value[@Type=\'OnCard\']'); |
||
| 80 | } |
||
| 81 | |||
| 82 | if ($balance->length > 0) { |
||
| 83 | $analyzeResponse->response->Success->VirtualCard->Amount = |
||
| 84 | $balance->item(0)->getAttribute('Amount'); |
||
| 85 | $analyzeResponse->response->Success->VirtualCard->DecimalPlaces = |
||
| 86 | $balance->item(0)->getAttribute('DecimalPlaces'); |
||
| 87 | $analyzeResponse->response->Success->VirtualCard->CurrencyCode = |
||
| 88 | $balance->item(0)->getAttribute('CurrencyCode'); |
||
| 89 | } |
||
| 90 | |||
| 91 | return $analyzeResponse; |
||
| 92 | } |
||
| 126 |