ConfirmCar::__construct()   A
last analyzed

Complexity

Conditions 6
Paths 32

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 26
ccs 21
cts 21
cp 1
rs 9.2222
cc 6
nc 32
nop 1
crap 6
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\Offer;
24
25
use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException;
26
use Amadeus\Client\RequestOptions\OfferConfirmCarOptions;
27
use Amadeus\Client\Struct\BaseWsMessage;
28
use Amadeus\Client\Struct\Offer\ConfirmCar\AddressUsageDetails;
29
use Amadeus\Client\Struct\Offer\ConfirmCar\DeliveryAndCollection;
30
use Amadeus\Client\Struct\Offer\ConfirmCar\PaxTattooNbr;
31
use Amadeus\Client\Struct\Offer\ConfirmCar\PnrInfo;
32
use Amadeus\Client\Struct\Offer\ConfirmCar\TattooReference;
33
use Amadeus\Client\Struct\Pnr\Retrieve\ReservationOrProfileIdentifier;
34
35
/**
36
 * Offer_ConfirmCarOffer
37
 *
38
 * @package Amadeus\Client\Struct\Offer
39
 * @author Dieter Devlieghere <[email protected]>
40
 */
41
class ConfirmCar extends BaseWsMessage
42
{
43
    /**
44
     * @var ConfirmCar\PnrInfo
45
     */
46
    public $pnrInfo;
47
48
    public $bookingType;
49
50
    /**
51
     * @var ConfirmCar\DeliveryAndCollection[]
52
     */
53
    public $deliveryAndCollection = [];
54
55
    public $vehicleInformation;
56
57
    public $arrivalInfo;
58
59
    public $fFlyerNbr;
60
61
    public $rateInfo;
62
63
    public $payment;
64
65
    public $attributeData;
66
67
    public $billingData;
68
69
    public $supleInfo;
70
71
    public $estimatedDistance;
72
73
    public $agentInformation;
74
75
    public $trackingOpt;
76
77
    public $customerEmail;
78
79
    public $retryProcess;
80
81
    public $ruleReference;
82
83
    public $action;
84
85
    /**
86
     * ConfirmCar constructor.
87
     *
88
     * @param OfferConfirmCarOptions $params
89
     * @throws MessageVersionUnsupportedException
90
     */
91 10
    public function __construct($params)
92
    {
93 10
        $this->pnrInfo = new PnrInfo();
94
95 10
        if (!empty($params->passengerTattoo)) {
96 10
            $this->pnrInfo->paxTattooNbr = new PaxTattooNbr($params->passengerTattoo);
97 4
        }
98
99 10
        if (!empty($params->offerTattoo)) {
100 10
            $this->pnrInfo->tattooReference = new TattooReference($params->offerTattoo);
101 4
        }
102
103 10
        if (!empty($params->recordLocator)) {
104 5
            $this->pnrInfo->pnrRecLoc = new ReservationOrProfileIdentifier($params->recordLocator);
105 2
        }
106
107 10
        if (!empty($params->pickUpInfo)) {
108 5
            $this->deliveryAndCollection[] = new DeliveryAndCollection(
109 5
                AddressUsageDetails::PURPOSE_COLLECTION,
110 5
                $params->pickUpInfo
111 2
            );
112 2
        }
113 10
        if (!empty($params->dropOffInfo)) {
114 5
            $this->deliveryAndCollection[] = new DeliveryAndCollection(
115 5
                AddressUsageDetails::PURPOSE_DELIVERY,
116 5
                $params->dropOffInfo
117 2
            );
118 2
        }
119 10
    }
120
}
121