Completed
Push — master ( 0b0e41...92762b )
by Dieter
06:46
created

Traveller::loadBirthDate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
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\Air\RetrieveSeatMap;
24
25
use Amadeus\Client\RequestOptions\Air\RetrieveSeatMap\FrequentFlyer;
26
use Amadeus\Client\RequestOptions\Air\RetrieveSeatMap\Traveller as TravellerOpt;
27
28
/**
29
 * Traveller
30
 *
31
 * @package Amadeus\Client\Struct\Air\RetrieveSeatMap
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class Traveller
35
{
36
    /**
37
     * @var TravelerInformation
38
     */
39
    public $travelerInformation;
40
41
    /**
42
     * @var FrequentTravelerDetails[]
43
     */
44
    public $frequentTravelerDetails = [];
45
46
    /**
47
     * @var FareInfo
48
     */
49
    public $fareInfo;
50
51
    /**
52
     * @var DateAndTimeInfo
53
     */
54
    public $dateAndTimeInfo;
55
56
    /**
57
     * @var TicketDetails
58
     */
59
    public $ticketDetails;
60
61
    /**
62
     * @var FareQualifierDetails
63
     */
64
    public $fareQualifierDetails;
65
66
    /**
67
     * @var CustomerCharacteristics[]
68
     */
69
    public $customerCharacteristics = [];
70
71
    /**
72
     * Traveller constructor.
73
     *
74
     * @param TravellerOpt $travellerOpt
75
     */
76
    public function __construct($travellerOpt)
77
    {
78
        $this->travelerInformation = new TravelerInformation($travellerOpt);
79
80
        $this->loadFrequentTraveller($travellerOpt->frequentTravellerInfo);
81
82
        $this->loadFareInfo($travellerOpt->passengerTypeCode, $travellerOpt->ticketDesignator);
83
84
        $this->loadBirthDate($travellerOpt->dateOfBirth);
85
86
        $this->loadTicketDetails($travellerOpt->ticketNumber);
87
88
        $this->loadFareQualifierDetails($travellerOpt->fareBasisOverride);
89
    }
90
91
    /**
92
     * @param FrequentFlyer|null $freqTrav
93
     */
94
    protected function loadFrequentTraveller($freqTrav)
95
    {
96
        if (!is_null($freqTrav)) {
97
            $this->frequentTravelerDetails[] = new FrequentTravelerDetails($freqTrav);
98
        }
99
    }
100
101
    /**
102
     * @param string|null $passTypeCode
103
     * @param string|null $ticketDesignator
104
     */
105
    protected function loadFareInfo($passTypeCode, $ticketDesignator)
106
    {
107
        if (!is_null($passTypeCode) || !is_null($ticketDesignator)) {
108
            $this->fareInfo = new FareInfo($passTypeCode, $ticketDesignator);
109
        }
110
    }
111
112
    /**
113
     * @param \DateTime|null $dateOfBirth
114
     */
115
    protected function loadBirthDate($dateOfBirth)
116
    {
117
        if ($dateOfBirth instanceof \DateTime) {
118
            $this->dateAndTimeInfo = new DateAndTimeInfo($dateOfBirth);
119
        }
120
    }
121
122
    /**
123
     * @param string|null $ticketNumber
124
     */
125
    protected function loadTicketDetails($ticketNumber)
126
    {
127
        if (!is_null($ticketNumber)) {
128
            $this->ticketDetails = new TicketDetails($ticketNumber);
129
        }
130
    }
131
132
    /**
133
     * @param string|null $fareBasisOverride
134
     */
135
    protected function loadFareQualifierDetails($fareBasisOverride)
136
    {
137
        if (!is_null($fareBasisOverride)) {
138
            $this->fareQualifierDetails = new FareQualifierDetails($fareBasisOverride);
139
        }
140
    }
141
}
142