Passed
Push — master ( a2100c...af4f13 )
by Andrey
06:37
created

AuthorizationDetailsConverter::convert()   F

Complexity

Conditions 11
Paths 1024

Size

Total Lines 49
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 25
nc 1024
nop 1
dl 0
loc 49
rs 3.1764
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\AmazonpayAuthorizationDetailsTransfer;
1 ignored issue
show
Bug introduced by
The type Generated\Shared\Transfe...rizationDetailsTransfer 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 AuthorizationDetailsConverter extends AbstractArrayConverter
14
{
15
16
    const PAYMENT_METHOD_INVALID = 'InvalidPaymentMethod';
17
18
    /**
19
     * @param array $authDetailsData
20
     *
21
     * @return \Generated\Shared\Transfer\AmazonpayAuthorizationDetailsTransfer
22
     */
23
    public function convert(array $authDetailsData)
24
    {
25
        $authorizationDetails = new AmazonpayAuthorizationDetailsTransfer();
26
        $authorizationDetails->setAmazonAuthorizationId($authDetailsData['AmazonAuthorizationId']);
27
        $authorizationDetails->setAuthorizationReferenceId($authDetailsData['AuthorizationReferenceId']);
28
29
        if (!empty($authDetailsData['AuthorizationAmount'])) {
30
            $authorizationDetails->setAuthorizationAmount($this->convertPriceToTransfer($authDetailsData['AuthorizationAmount']));
31
        }
32
33
        if (!empty($authDetailsData['CapturedAmount'])) {
34
            $authorizationDetails->setAuthorizationAmount($this->convertPriceToTransfer($authDetailsData['CapturedAmount']));
35
        }
36
37
        if (!empty($authDetailsData['AuthorizationFee'])) {
38
            $authorizationDetails->setAuthorizationAmount($this->convertPriceToTransfer($authDetailsData['AuthorizationFee']));
39
        }
40
41
        if (!empty($authDetailsData['AuthorizationStatus'])) {
42
            $authorizationDetails->setAuthorizationStatus(
43
                $this->convertStatusToTransfer($authDetailsData['AuthorizationStatus'])
44
            );
45
        }
46
47
        if (!empty($authDetailsData['ExpirationTimestamp'])) {
48
            $authorizationDetails->setExpirationTimestamp($authDetailsData['ExpirationTimestamp']);
49
        }
50
51
        if (!empty($authDetailsData['IdList'])) {
52
            $authorizationDetails->setIdList(array_values($authDetailsData['IdList'])[0]);
53
        }
54
55
        if (!empty($authDetailsData['SoftDecline'])) {
56
            $authorizationDetails->setSoftDecline($authDetailsData['SoftDecline']);
57
        }
58
59
        if (!empty($authDetailsData['CaptureNow'])) {
60
            $authorizationDetails->setCaptureNow($authDetailsData['CaptureNow']);
61
        }
62
63
        if (!empty($authDetailsData['SellerAuthorizationNote'])) {
64
            $authorizationDetails->setSellerAuthorizationNote($authDetailsData['CaptureNow']);
65
        }
66
67
        if (!empty($authDetailsData['CreationTimestamp'])) {
68
            $authorizationDetails->setCreationTimestamp($authDetailsData['CreationTimestamp']);
69
        }
70
71
        return $authorizationDetails;
72
    }
73
74
}
75