Passed
Push — master ( b4fa7d...fc09a3 )
by Artem
03:30
created

GetVirtualCardDetails::__construct()   A

Complexity

Conditions 5
Paths 12

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 16
rs 9.6111
cc 5
nc 12
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\PayGetVirtualCardDetailsOptions;
27
use Amadeus\Client\Struct\BaseWsMessage;
28
use Amadeus\Client\Struct\InvalidArgumentException;
29
30
/**
31
 * GetVirtualCardDetails
32
 *
33
 * @package Amadeus\Client\Struct\Pay
34
 * @author Konstantin Bogomolov <[email protected]>
35
 */
36
class GetVirtualCardDetails extends BaseWsMessage
37
{
38
    public $Version = '2.0';
39
40
    /**
41
     * @var Reference[]
42
     */
43
    public $References;
44
45
    public $DisplayFilter;
46
47
    /**
48
     * GetVirtualCardDetails constructor.
49
     * @param PayGetVirtualCardDetailsOptions $params
50
     */
51
    public function __construct(PayGetVirtualCardDetailsOptions $params)
52
    {
53
        if ($params->amadeusReference !== null) {
54
            $this->References[] = new Reference(Reference::TYPE_AMADEUS, $params->amadeusReference);
55
        }
56
57
        if ($params->externalReference !== null) {
58
            $this->References[] = new Reference(Reference::TYPE_EXTERNAL, $params->externalReference);
59
        }
60
61
        if (empty($this->References)) {
62
            throw new InvalidArgumentException('At least one Reference in GetVirtualCardDetails options is mandatory');
63
        }
64
65
        if (null !== $params->displayFilter) {
66
            $this->DisplayFilter = $params->displayFilter;
67
        }
68
    }
69
}
70