Completed
Push — master ( 251d07...973a55 )
by Oleksandr
10s
created

StoreOrderRequestConverter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 17.78 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 8
loc 45
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convert() 0 4 1
B convertOrder() 8 27 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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