VirtualCard::__construct()   B
last analyzed

Complexity

Conditions 9
Paths 39

Size

Total Lines 39
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 39
rs 8.0555
cc 9
nc 39
nop 1
1
<?php
2
3
/**
4
 * amadeus-ws-client
5
 *
6
 * Copyright 2015 Amadeus Benelux NV
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 *
20
 * @package Amadeus
21
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
22
 */
23
24
namespace Amadeus\Client\Struct\Pay;
25
26
use Amadeus\Client\RequestOptions\PayGenerateVirtualCardOptions;
27
use Amadeus\Client\Struct\InvalidArgumentException;
28
29
/**
30
 * VirtualCard
31
 *
32
 * @package Amadeus\Client\Struct\Pay
33
 * @author Konstantin Bogomolov <[email protected]>
34
 */
35
class VirtualCard
36
{
37
    /**
38
     * @var string
39
     */
40
    public $CardName;
41
42
    /**
43
     * @var string
44
     */
45
    public $SubType;
46
47
    /**
48
     * @var string
49
     */
50
    public $CurrencyCode;
51
52
    /**
53
     * @var string
54
     */
55
    public $VendorCode;
56
57
    /**
58
     * @var boolean
59
     */
60
    public $ReturnCVV;
61
62
    /**
63
     * For DEBIT and PREPAID cards Amount to be loaded on the card
64
     * For CREDIT cards Credit limit
65
     * @var int
66
     */
67
    public $Amount;
68
69
    /**
70
     * @var int
71
     */
72
    public $DecimalPlaces;
73
74
    /**
75
     * @var Limitations
76
     */
77
    public $Limitations;
78
79
    /**
80
     * VirtualCard constructor.
81
     *
82
     * @param PayGenerateVirtualCardOptions $params
83
     */
84
    public function __construct(PayGenerateVirtualCardOptions $params)
85
    {
86
        if ($params->CardName !== null) {
87
            if (strlen($params->CardName) > 35) {
88
                throw new InvalidArgumentException('Max card name length is 35 characters');
89
            }
90
91
            $this->CardName = $params->CardName;
92
        }
93
94
        if ($params->Amount === null) {
95
            throw new InvalidArgumentException('Amount is required');
96
        }
97
98
        if ($params->DecimalPlaces !== null) {
99
            $this->DecimalPlaces = $params->DecimalPlaces;
100
        }
101
102
        $this->Amount = $params->Amount;
103
104
        if ($params->CurrencyCode === null) {
105
            throw new InvalidArgumentException('Currency code is required');
106
        }
107
108
        $this->CurrencyCode = $params->CurrencyCode;
109
110
        if ($params->SubType !== null) {
111
            $this->SubType = $params->SubType;
112
        }
113
114
        if ($params->VendorCode !== null) {
115
            $this->VendorCode = $params->VendorCode;
116
        }
117
118
        if ($params->ReturnCVV !== null) {
119
            $this->ReturnCVV = $params->ReturnCVV;
120
        }
121
122
        $this->Limitations = new Limitations($params);
123
    }
124
}
125