| Conditions | 9 |
| Paths | 192 |
| Total Lines | 57 |
| Code Lines | 42 |
| 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 | private function getHeader(array $arrayParams): array |
||
| 38 | { |
||
| 39 | $arrayCBC = explode(':', $arrayParams['DocumentNameSpaces']['cbc']); |
||
| 40 | $strCBC = $arrayCBC[count($arrayCBC) - 1]; // CommonBasicComponents |
||
| 41 | $strCAC = $arrayParams['cacName']; // CommonAggregateComponents |
||
| 42 | $arrayDocument = [ |
||
| 43 | $strCBC => $this->getHeaderCommonBasicComponents($arrayParams['DocumentTagName'], $arrayParams['CBC']), |
||
| 44 | $strCAC => [ |
||
| 45 | 'AccountingCustomerParty' => $this->getAccountingCustomerParty($arrayParams['CAC'] |
||
| 46 | ->AccountingCustomerParty->children('cac', true)->Party), |
||
| 47 | 'AccountingSupplierParty' => $this->getAccountingSupplierParty($arrayParams['CAC'] |
||
| 48 | ->AccountingSupplierParty->children('cac', true)->Party), |
||
| 49 | 'LegalMonetaryTotal' => $this->getLegalMonetaryTotal($arrayParams['CAC']->LegalMonetaryTotal), |
||
| 50 | 'TaxTotal' => $this->getTaxTotal($arrayParams['CAC']->TaxTotal), |
||
| 51 | ], |
||
| 52 | ]; |
||
| 53 | // optional components ========================================================================================= |
||
| 54 | if (isset($arrayParams['CAC']->PaymentMeans)) { |
||
| 55 | $arrayDocument[$strCAC]['PaymentMeans'] = $this->getMultipleElements($arrayParams['CAC']->PaymentMeans); |
||
| 56 | } |
||
| 57 | if (isset($arrayParams['CAC']->PaymentTerms)) { |
||
| 58 | $arrayDocument[$strCAC]['PaymentTerms']['Note'] = $arrayParams['CAC'] |
||
| 59 | ->PaymentTerms->children('cbc', true)->Note->__toString(); |
||
| 60 | } |
||
| 61 | if (isset($arrayParams['CAC']->InvoicePeriod)) { |
||
| 62 | $arrayDocument[$strCAC]['InvoicePeriod'] = $this->getLegalInvoicePeriod($arrayParams['CAC']->InvoicePeriod); |
||
| 63 | } |
||
| 64 | if (isset($arrayParams['CAC']->ContractDocumentReference)) { |
||
| 65 | $arrayDocument[$strCAC]['ContractDocumentReference']['ID'] = $arrayParams['CAC'] |
||
| 66 | ->ContractDocumentReference->children('cbc', true)->ID->__toString(); |
||
| 67 | } |
||
| 68 | if (isset($arrayParams['CAC']->OrderReference)) { |
||
| 69 | $arrayDocument[$strCAC]['OrderReference']['ID'] = $arrayParams['CAC'] |
||
| 70 | ->OrderReference->children('cbc', true)->ID->__toString(); |
||
| 71 | } |
||
| 72 | if (isset($arrayParams['CAC']->AdditionalDocumentReference)) { |
||
| 73 | $arrayDocument[$strCAC]['AdditionalDocumentReference'] = $this->getMultipleElementsStandard($arrayParams['CAC'] |
||
| 74 | ->AdditionalDocumentReference); |
||
| 75 | } |
||
| 76 | if (isset($arrayParams['CAC']->Delivery)) { |
||
| 77 | $strEl = $arrayParams['CAC']->Delivery; |
||
| 78 | $strElement = $strEl->children('cac', true) |
||
| 79 | ->DeliveryLocation->children('cac', true)->Address; |
||
| 80 | $arrayDocument[$strCAC]['Delivery']['DeliveryLocation']['Address'] = [ |
||
| 81 | 'StreetName' => $strElement->children('cbc', true)->StreetName->__toString(), |
||
| 82 | 'CityName' => $strElement->children('cbc', true)->CityName->__toString(), |
||
| 83 | 'PostalZone' => $strElement->children('cbc', true)->PostalZone->__toString(), |
||
| 84 | 'Country' => [ |
||
| 85 | 'IdentificationCode' => $strElement->children('cac', true)->Country->children('cbc', true)->IdentificationCode->__toString(), |
||
| 86 | ], |
||
| 87 | ]; |
||
| 88 | if (isset($strEl->children('cbc', true)->ActualDeliveryDate)) { |
||
| 89 | $arrayDocument[$strCAC]['Delivery']['ActualDeliveryDate'] = $strEl |
||
| 90 | ->children('cbc', true)->ActualDeliveryDate->__toString(); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | return $arrayDocument; |
||
| 94 | } |
||
| 198 |