Completed
Push — fopcreatefop ( 97f2d4...a66afc )
by Dieter
07:35
created

TdsInformation::__construct()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 28
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 32
c 0
b 0
f 0
ccs 28
cts 28
cp 1
rs 8.439
cc 5
eloc 20
nc 16
nop 1
crap 5
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 2
    public function __construct(ThreeDSecureInfo $options)
57
    {
58 2
        if (!empty($options->acsUrl)) {
59 1
            $this->acsURL = new AcsUrl($options->acsUrl);
60 1
        }
61
62 2
        if ($this->checkAnyNotEmpty($options->veresStatus, $options->paresStatus, $options->creditCardCompany)) {
63 2
            $this->authenticationData = new AuthenticationData(
64 2
                $options->veresStatus,
65 2
                $options->paresStatus,
66 2
                $options->creditCardCompany
67 2
            );
68 2
        }
69
70 2
        if (!empty($options->transactionIdentifier)) {
71 2
            $this->tdsBlobData[] = new TdsBlobData(
72 2
                TdsReferenceDetails::REF_THREEDS_TRANSACTION_IDENTIFIER,
73 2
                $options->transactionIdentifier,
74 2
                $options->transactionIdentifierDataType,
75 2
                $options->transactionIdentifierLength
76 2
            );
77 2
        }
78
79 2
        if (!empty($options->paresAuthResponse)) {
80 2
            $this->tdsBlobData[] = new TdsBlobData(
81 2
                TdsReferenceDetails::REF_PARES,
82 2
                $options->paresAuthResponse,
83 2
                $options->paresAuthResponseDataType,
84 2
                $options->paresAuthResponseLength
85 2
            );
86 2
        }
87 2
    }
88
}
89