Passed
Pull Request — dev (#9)
by Andrey
07:45 queued 04:11
created

RefundDetailsConverter::convert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Apache OSL-2
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\AmazonPay\Business\Api\Converter\Details;
9
10
use Generated\Shared\Transfer\AmazonpayRefundDetailsTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...ayRefundDetailsTransfer 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 SprykerEco\Zed\AmazonPay\Business\Api\Converter\AbstractArrayConverter;
12
13
class RefundDetailsConverter extends AbstractArrayConverter
14
{
15
    const REFUND_AMOUNT = 'RefundAmount';
16
    const REFUND_STATUS = 'RefundStatus';
17
18
    /**
19
     * @param array $refundDetailsData
20
     *
21
     * @return \Generated\Shared\Transfer\AmazonpayRefundDetailsTransfer
22
     */
23
    public function convert(array $refundDetailsData)
24
    {
25
        $refundDetails = new AmazonpayRefundDetailsTransfer();
26
        $refundDetails->fromArray($refundDetailsData, true);
27
28
        $this->hydrateRefundAmount($refundDetailsData, $refundDetails);
29
30
        $this->hydrateStatus($refundDetailsData, $refundDetails);
31
32
        return $refundDetails;
33
    }
34
35
    /**
36
     * @param array $refundDetailsData
37
     * @param \Generated\Shared\Transfer\AmazonpayRefundDetailsTransfer $refundDetails
38
     *
39
     * @return void
40
     */
41
    protected function hydrateRefundAmount(array $refundDetailsData, AmazonpayRefundDetailsTransfer $refundDetails)
42
    {
43
        $refundDetails->setRefundAmount(
44
            $this->convertPriceToTransfer(
45
                $refundDetailsData[static::REFUND_AMOUNT]
46
            )
47
        );
48
    }
49
50
    /**
51
     * @param array $refundDetailsData
52
     * @param \Generated\Shared\Transfer\AmazonpayRefundDetailsTransfer $refundDetails
53
     *
54
     * @return void
55
     */
56
    protected function hydrateStatus(array $refundDetailsData, AmazonpayRefundDetailsTransfer $refundDetails)
57
    {
58
        if (!empty($refundDetailsData[static::REFUND_STATUS])) {
59
            $refundDetails->setRefundStatus(
60
                $this->convertStatusToTransfer($refundDetailsData[static::REFUND_STATUS])
61
            );
62
        }
63
    }
64
}
65