TdsInformation::__construct()   B
last analyzed

Complexity

Conditions 8
Paths 128

Size

Total Lines 66
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 8

Importance

Changes 0
Metric Value
eloc 46
c 0
b 0
f 0
dl 0
loc 66
ccs 28
cts 28
cp 1
rs 7.747
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(
63 10
            $options->veresStatus,
64 10
            $options->paresStatus,
65 10
            $options->creditCardCompany,
66 10
            $options->transactionsStatus,
67 4
            $options->authenticationIndicator,
68 4
            $options->tdsVersion,
69
        )) {
70 10
            $this->authenticationData = new AuthenticationData(
71 10
                $options->veresStatus,
72 10
                $options->paresStatus,
73 10
                $options->creditCardCompany,
74 10
                $options->transactionsStatus,
75 10
                $options->authenticationIndicator,
76 4
                $options->tdsVersion
77 4
            );
78
        }
79 10
80 10
        if (!empty($options->transactionIdentifier)) {
81 10
            $this->tdsBlobData[] = new TdsBlobData(
82 10
                TdsReferenceDetails::REF_THREEDS_TRANSACTION_IDENTIFIER,
83 10
                $options->transactionIdentifier,
84 10
                $options->transactionIdentifierDataType,
85 4
                $options->transactionIdentifierLength
86 4
            );
87 10
        }
88
89
        if (!empty($options->tdsServerTransactionId)) {
90
            $this->tdsBlobData[] = new TdsBlobData(
91
                TdsReferenceDetails::REG_THREEDS_SERVER_TRANSACTION_ID,
92
                $options->tdsServerTransactionId,
93
                $options->tdsServerTransactionIdDataType,
94
                $options->tdsServerTransactionIdLength
95
            );
96
        }
97
98
        if (!empty($options->tdsAuthenticationVerificationCode)) {
99
            $this->tdsBlobData[] = new TdsBlobData(
100
                $options->tdsAuthenticationVerificationCodeReference,
101
                $options->tdsAuthenticationVerificationCode,
102
                $options->tdsAuthenticationVerificationCodeDataType,
103
                $options->tdsAuthenticationVerificationCodeLength
104
            );
105
        }
106
107
        if (!empty($options->directoryServerTransactionId)) {
108
            $this->tdsBlobData[] = new TdsBlobData(
109
                TdsReferenceDetails::REG_DIRECTORY_SERVER_TRANSACTION_ID,
110
                $options->directoryServerTransactionId,
111
                $options->directoryServerTransactionIdDataType,
112
                $options->directoryServerTransactionIdLength
113
            );
114
        }
115
116
        if (!empty($options->paresAuthResponse)) {
117
            $this->tdsBlobData[] = new TdsBlobData(
118
                TdsReferenceDetails::REF_PARES,
119
                $options->paresAuthResponse,
120
                $options->paresAuthResponseDataType,
121
                $options->paresAuthResponseLength
122
            );
123
        }
124
    }
125
}
126