Completed
Pull Request — master (#64)
by
unknown
06:13 queued 10s
created

OrderHandlingMapper::prepareOrderHandling()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 31
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 31
rs 9.552
cc 3
nc 3
nop 2
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\Payone\Business\Payment\DataMapper;
9
10
use Generated\Shared\Transfer\OrderTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\OrderTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Spryker\Shared\Shipment\ShipmentConfig;
12
use SprykerEco\Shared\Payone\PayoneApiConstants;
13
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer;
14
15
class OrderHandlingMapper implements OrderHandlingMapperInterface
16
{
17
    protected const HANDLING_PRODUCT_DESCRIPTION = 'Handling';
18
    protected const ZERRO_ITEM_TAX_RATE = 0;
19
    protected const ONE_ITEM_AMOUNT = 1;
20
21
    /**
22
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
23
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $container
24
     *
25
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer
26
     */
27
    public function prepareOrderHandling(OrderTransfer $orderTransfer, AbstractRequestContainer $container): AbstractRequestContainer
28
    {
29
        $arrayIt = $container->getIt() ?? [];
30
        $arrayId = $container->getId() ?? [];
31
        $arrayPr = $container->getPr() ?? [];
32
        $arrayNo = $container->getNo() ?? [];
33
        $arrayDe = $container->getDe() ?? [];
34
        $arrayVa = $container->getVa() ?? [];
35
36
        $key = count($arrayId) + 1;
37
38
        foreach ($orderTransfer->getExpenses() as $expense) {
39
            if ($expense->getType() !== ShipmentConfig::SHIPMENT_EXPENSE_TYPE) {
40
                $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_HANDLING;
41
                $arrayId[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_HANDLING;
42
                $arrayPr[$key] = $expense->getSumGrossPrice();
43
                $arrayNo[$key] = static::ONE_ITEM_AMOUNT;
44
                $arrayDe[$key] = static::HANDLING_PRODUCT_DESCRIPTION;
45
                $arrayVa[$key] = static::ZERRO_ITEM_TAX_RATE;
46
                $key++;
47
            }
48
        }
49
50
        $container->setIt($arrayIt);
51
        $container->setId($arrayId);
52
        $container->setPr($arrayPr);
53
        $container->setNo($arrayNo);
54
        $container->setDe($arrayDe);
55
        $container->setVa($arrayVa);
56
57
        return $container;
58
    }
59
}
60