Passed
Pull Request — master (#67)
by
unknown
09:59
created

DiscountMapper   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 24
c 1
b 0
f 0
dl 0
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mapDiscounts() 0 26 1
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 SprykerEco\Shared\Payone\PayoneApiConstants;
11
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer;
12
13
class DiscountMapper implements DiscountMapperInterface
14
{
15
    protected const ZERRO_ITEM_TAX_RATE = 0;
16
    protected const DISCOUNT_PRODUCT_DESCRIPTION = 'Discount';
17
    protected const ONE_ITEM_AMOUNT = 1;
18
19
    /**
20
     * @param \Generated\Shared\Transfer\OrderTransfer|\Generated\Shared\Transfer\QuoteTransfer $discountContainer
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\QuoteTransfer 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...
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...
21
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $container
22
     *
23
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer
24
     */
25
    public function mapDiscounts($discountContainer, AbstractRequestContainer $container): AbstractRequestContainer
26
    {
27
        $arrayIt = $container->getIt() ?? [];
28
        $arrayId = $container->getId() ?? [];
29
        $arrayPr = $container->getPr() ?? [];
30
        $arrayNo = $container->getNo() ?? [];
31
        $arrayDe = $container->getDe() ?? [];
32
        $arrayVa = $container->getVa() ?? [];
33
34
        $key = count($arrayId) + 1;
35
36
        $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_VOUCHER;
37
        $arrayId[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_VOUCHER;
38
        $arrayPr[$key] = - $discountContainer->getTotals()->getDiscountTotal();
39
        $arrayNo[$key] = static::ONE_ITEM_AMOUNT;
40
        $arrayDe[$key] = static::DISCOUNT_PRODUCT_DESCRIPTION;
41
        $arrayVa[$key] = static::ZERRO_ITEM_TAX_RATE;
42
43
        $container->setIt($arrayIt);
44
        $container->setId($arrayId);
45
        $container->setPr($arrayPr);
46
        $container->setNo($arrayNo);
47
        $container->setDe($arrayDe);
48
        $container->setVa($arrayVa);
49
50
        return $container;
51
    }
52
}
53