1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MIT License |
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\ArvatoRss\Business\Api\Converter; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ArvatoRssStoreOrderRequestTransfer; |
11
|
|
|
use SprykerEco\Zed\ArvatoRss\Business\Api\ArvatoRssRequestApiConfig; |
12
|
|
|
|
13
|
|
|
class StoreOrderRequestConverter implements StoreOrderRequestConverterInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @param \Generated\Shared\Transfer\ArvatoRssStoreOrderRequestTransfer $arvatoRssStoreOrderRequestTransfer |
17
|
|
|
* |
18
|
|
|
* @return array |
19
|
|
|
*/ |
20
|
|
|
public function convert(ArvatoRssStoreOrderRequestTransfer $arvatoRssStoreOrderRequestTransfer) |
21
|
|
|
{ |
22
|
|
|
return $this->convertOrder($arvatoRssStoreOrderRequestTransfer); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param \Generated\Shared\Transfer\ArvatoRssStoreOrderRequestTransfer $arvatoRssStoreOrderRequestTransfer |
27
|
|
|
* |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
protected function convertOrder(ArvatoRssStoreOrderRequestTransfer $arvatoRssStoreOrderRequestTransfer) |
31
|
|
|
{ |
32
|
|
|
$result = []; |
33
|
|
|
$order = $arvatoRssStoreOrderRequestTransfer->getOrder(); |
34
|
|
|
|
35
|
|
|
$result[ArvatoRssRequestApiConfig::ARVATORSS_API_ORDER] = [ |
36
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_REGISTEREDORDER => $order->getRegisteredOrder(), |
37
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_ORDER_NUMBER => $order->getOrderNumber(), |
38
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_DEBITOR_NUMBER => $order->getDebitorNumber(), |
39
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_PAYMENT_TYPE => $order->getPaymentType(), |
40
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_CURRENCY => $order->getCurrency(), |
41
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_GROSSTOTALBILL => $order->getGrossTotalBill(), |
42
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_TOTALORDERVALUE => $order->getTotalOrderValue(), |
43
|
|
|
]; |
44
|
|
|
$result[ArvatoRssRequestApiConfig::ARVATORSS_API_ORDER][ArvatoRssRequestApiConfig::ARVATORSS_API_ITEM] = []; |
45
|
|
|
|
46
|
|
View Code Duplication |
foreach ($order->getItems() as $item) { |
|
|
|
|
47
|
|
|
$result[ArvatoRssRequestApiConfig::ARVATORSS_API_ORDER][ArvatoRssRequestApiConfig::ARVATORSS_API_ITEM][] = [ |
48
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_PRODUCTNUMBER => $item->getProductNumber(), |
49
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_PRODUCTGROUPID => $item->getProductGroupId(), |
50
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_UNITPRICE => $item->getUnitPrice(), |
51
|
|
|
ArvatoRssRequestApiConfig::ARVATORSS_API_UNITCOUNT => $item->getUnitCount(), |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $result; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.