FraudScreeningData::__construct()   B
last analyzed

Complexity

Conditions 8
Paths 128

Size

Total Lines 34
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 8

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 34
ccs 26
cts 26
cp 1
rs 8.2111
cc 8
nc 128
nop 1
crap 8
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\FraudScreeningOptions;
26
use Amadeus\Client\Struct\WsMessageUtility;
27
28
/**
29
 * FraudScreeningData
30
 *
31
 * @package Amadeus\Client\Struct\Fop
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class FraudScreeningData extends WsMessageUtility
35
{
36
    /**
37
     * @var FraudScreening
38
     */
39
    public $fraudScreening;
40
41
    /**
42
     * @var IpAdress
43
     */
44
    public $ipAdress;
45
46
    /**
47
     * @var MerchantUrl
48
     */
49
    public $merchantURL;
50
51
    /**
52
     * @var PayerPhoneOrEmail[]
53
     */
54
    public $payerPhoneOrEmail = [];
55
56
    /**
57
     * @var ShopperSession
58
     */
59
    public $shopperSession;
60
61
    /**
62
     * @var PayerName
63
     */
64
    public $payerName;
65
66
    /**
67
     * @var PayerDateOfBirth
68
     */
69
    public $payerDateOfBirth;
70
71
    /**
72
     * @var BillingAddress
73
     */
74
    public $billingAddress;
75
76
    /**
77
     * @var FormOfIdDetails[]
78
     */
79
    public $formOfIdDetails = [];
80
81
    /**
82
     * @var TravelShopper
83
     */
84
    public $travelShopper;
85
86
    /**
87
     * @var ShopperDetails
88
     */
89
    public $shopperDetails;
90
91
    /**
92
     * @var SecurityCode[]
93
     */
94
    public $securityCode = [];
95
96
    /**
97
     * FraudScreeningData constructor.
98
     *
99
     * @param FraudScreeningOptions $options
100
     */
101 10
    public function __construct(FraudScreeningOptions $options)
102
    {
103 10
        $this->fraudScreening = new FraudScreening($options->doFraudScreening);
104
105 10
        if (!empty($options->ipAddress)) {
106 5
            $this->ipAdress = new IpAdress($options->ipAddress);
107 2
        }
108
109 10
        if (!empty($options->phone)) {
110 5
            $this->payerPhoneOrEmail[] = new PayerPhoneOrEmail(PayerPhoneOrEmail::TYPE_PHONE, $options->phone);
111 2
        }
112
113 10
        if (!empty($options->email)) {
114 5
            $this->payerPhoneOrEmail[] = new PayerPhoneOrEmail(PayerPhoneOrEmail::TYPE_EMAIL, $options->email);
115 2
        }
116
117 10
        if ($this->checkAnyNotEmpty($options->firstName, $options->lastName)) {
118 5
            $this->payerName = new PayerName($options->lastName, $options->firstName);
119 2
        }
120
121 10
        if ($options->dateOfBirth instanceof \DateTime) {
0 ignored issues
show
introduced by
$options->dateOfBirth is always a sub-type of DateTime.
Loading history...
122 5
            $this->payerDateOfBirth = new PayerDateOfBirth($options->dateOfBirth);
123 2
        }
124
125 10
        if ($this->checkAnyNotEmpty($options->idDocumentNr, $options->idDocumentType)) {
126 5
            $this->formOfIdDetails[] = new FormOfIdDetails($options->idDocumentNr, $options->idDocumentType);
127 2
        }
128
129 10
        if (!empty($options->billingAddress)) {
130 5
            $this->billingAddress = new BillingAddress(
131 5
                $options->billingAddress->addressLines,
132 5
                $options->billingAddress->city,
133 5
                $options->billingAddress->zipCode,
134 5
                $options->billingAddress->countryCode
135 2
            );
136 2
        }
137 10
    }
138
}
139