Passed
Pull Request — master (#481)
by Artem
05:43 queued 01:41
created

TdsInformation::__construct()   B

Complexity

Conditions 8
Paths 128

Size

Total Lines 59
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 8

Importance

Changes 0
Metric Value
eloc 40
c 0
b 0
f 0
dl 0
loc 59
ccs 28
cts 28
cp 1
rs 7.8488
cc 8
nc 128
nop 1
crap 8

How to fix   Long Method   

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
 * amadeus-ws-client
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 * @package Amadeus
20
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
21
 */
22
23
namespace Amadeus\Client\Struct\Fop;
24
25
use Amadeus\Client\RequestOptions\Fop\ThreeDSecureInfo;
26
use Amadeus\Client\Struct\WsMessageUtility;
27
28
/**
29
 * TdsInformation
30
 *
31
 * @package Amadeus\Client\Struct\Fop
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class TdsInformation extends WsMessageUtility
35
{
36
    /**
37
     * @var AuthenticationData
38
     */
39
    public $authenticationData;
40
41
    /**
42
     * @var AcsUrl
43
     */
44
    public $acsURL;
45
46
    /**
47
     * @var TdsBlobData[]
48
     */
49
    public $tdsBlobData = [];
50
51
    /**
52
     * TdsInformation constructor.
53
     *
54
     * @param ThreeDSecureInfo $options
55
     */
56 10
    public function __construct(ThreeDSecureInfo $options)
57
    {
58 10
        if (!empty($options->acsUrl)) {
59 5
            $this->acsURL = new AcsUrl($options->acsUrl);
60 2
        }
61
62 10
        if ($this->checkAnyNotEmpty($options->veresStatus, $options->paresStatus, $options->creditCardCompany, $options->transactionsStatus, $options->authenticationIndicator, $options->tdsVersion)) {
63 10
            $this->authenticationData = new AuthenticationData(
64 10
                $options->veresStatus,
65 10
                $options->paresStatus,
66 10
                $options->creditCardCompany,
67 4
                $options->transactionsStatus,
68 4
                $options->authenticationIndicator,
69
                $options->tdsVersion
70 10
            );
71 10
        }
72 10
73 10
        if (!empty($options->transactionIdentifier)) {
74 10
            $this->tdsBlobData[] = new TdsBlobData(
75 10
                TdsReferenceDetails::REF_THREEDS_TRANSACTION_IDENTIFIER,
76 4
                $options->transactionIdentifier,
77 4
                $options->transactionIdentifierDataType,
78
                $options->transactionIdentifierLength
79 10
            );
80 10
        }
81 10
82 10
        if (!empty($options->tdsServerTransactionId)) {
83 10
            $this->tdsBlobData[] = new TdsBlobData(
84 10
                TdsReferenceDetails::REG_THREEDS_SERVER_TRANSACTION_ID,
85 4
                $options->tdsServerTransactionId,
86 4
                $options->tdsServerTransactionIdDataType,
87 10
                $options->tdsServerTransactionIdLength
88
            );
89
        }
90
91
        if (!empty($options->tdsAuthenticationVerificationCode)) {
92
            $this->tdsBlobData[] = new TdsBlobData(
93
                $options->tdsAuthenticationVerificationCodeReference,
94
                $options->tdsAuthenticationVerificationCode,
95
                $options->tdsAuthenticationVerificationCodeDataType,
96
                $options->tdsAuthenticationVerificationCodeLength
97
            );
98
        }
99
100
        if (!empty($options->directoryServerTransactionId)) {
101
            $this->tdsBlobData[] = new TdsBlobData(
102
                TdsReferenceDetails::REG_DIRECTORY_SERVER_TRANSACTION_ID,
103
                $options->directoryServerTransactionId,
104
                $options->directoryServerTransactionIdDataType,
105
                $options->directoryServerTransactionIdLength
106
            );
107
        }
108
109
        if (!empty($options->paresAuthResponse)) {
110
            $this->tdsBlobData[] = new TdsBlobData(
111
                TdsReferenceDetails::REF_PARES,
112
                $options->paresAuthResponse,
113
                $options->paresAuthResponseDataType,
114
                $options->paresAuthResponseLength
115
            );
116
        }
117
    }
118
}
119