Test Failed
Push — master ( d99a5b...94cf84 )
by Dieter
10:01
created

GetFareRules::loadFlightQualification()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 3
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\Fare;
24
25
use Amadeus\Client\RequestOptions\FareGetFareRulesOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\Fare\CheckRules\ItemNumber;
28
use Amadeus\Client\Struct\Fare\ConvertCurrency\ConversionRate;
29
use Amadeus\Client\Struct\Fare\GetFareRules\FlightQualification;
30
use Amadeus\Client\Struct\Fare\GetFareRules\MultiCorporate;
31
use Amadeus\Client\Struct\Fare\GetFareRules\PricingTickInfo;
32
use Amadeus\Client\Struct\Fare\GetFareRules\TransportInformation;
33
use Amadeus\Client\Struct\Fare\GetFareRules\TripDescription;
34
35
/**
36
 * Fare_GetFareRules request structure
37
 *
38
 * @package Amadeus\Client\Struct\Fare
39
 * @author Dieter Devlieghere <[email protected]>
40
 */
41
class GetFareRules extends BaseWsMessage
42
{
43
    /**
44
     * @var MsgType
45
     */
46
    public $msgType;
47
48
    /**
49
     * @var GetFareRules\AvailCabinConf
50
     */
51
    public $availCabinConf;
52
53
    /**
54
     * @var ConversionRate
55
     */
56
    public $conversionRate;
57
58
    /**
59
     * @var GetFareRules\PricingTickInfo
60
     */
61
    public $pricingTickInfo;
62
63
    /**
64
     * @var GetFareRules\MultiCorporate
65
     */
66
    public $multiCorporate;
67
68
    /**
69
     * @var GetFareRules\CorporateInfo
70
     */
71
    public $corporateInfo;
72
73
    /**
74
     * @var GetFareRules\MonetaryInfo
75
     */
76
    public $monetaryInfo;
77
78
    /**
79
     * @var ItemNumber
80
     */
81
    public $itemNumber;
82
83
    /**
84
     * @var GetFareRules\DateOfFlight
85
     */
86
    public $dateOfFlight;
87
88
    /**
89
     * @var GetFareRules\FlightQualification[]
90
     */
91
    public $flightQualification = [];
92
93
    /**
94
     * @var GetFareRules\TransportInformation[]
95
     */
96
    public $transportInformation = [];
97
98
    /**
99
     * @var GetFareRules\TripDescription[]
100
     */
101
    public $tripDescription = [];
102
103
    /**
104
     * @var GetFareRules\PricingInfo[]
105
     */
106
    public $pricingInfo = [];
107
108
    /**
109
     * @var GetFareRules\FareRule
110
     */
111
    public $fareRule;
112
113
    /**
114
     * @var GetFareRules\LocationInfo
115
     */
116
    public $locationInfo;
117
118
    /**
119
     * GetFareRules constructor.
120
     *
121
     * @param FareGetFareRulesOptions $options
122
     */
123
    public function __construct(FareGetFareRulesOptions $options)
124
    {
125
        $this->msgType = new MsgType(MessageFunctionDetails::FARE_GET_FARE_RULES);
126
127
        $this->loadTicketingDate($options->ticketingDate);
128
        $this->loadFlightQualification($options->fareBasis, $options->ticketDesignator, $options->directionality);
129
        $this->loadMultiCorporate($options->uniFares, $options->negoFares);
130
        $this->loadTransportInformation($options->airline);
131
        $this->loadTripDescription($options->origin, $options->destination, $options->travelDate);
132
    }
133
134
    /**
135
     * @param \DateTime|null $ticketingDate
136
     */
137
    protected function loadTicketingDate($ticketingDate)
138
    {
139
        if ($ticketingDate instanceof \DateTime) {
140
            $this->pricingTickInfo = new PricingTickInfo($ticketingDate);
141
        }
142
    }
143
144
    /**
145
     * @param string|null $fareBasis
146
     * @param string|null $ticketDesignator
147
     * @param string|null $directionality
148
     */
149
    protected function loadFlightQualification($fareBasis, $ticketDesignator, $directionality)
150
    {
151
        if ($this->checkAnyNotEmpty($fareBasis, $ticketDesignator, $directionality)) {
152
            $this->flightQualification[] = new FlightQualification(
153
                $fareBasis,
154
                $ticketDesignator,
155
                $directionality
156
            );
157
        }
158
    }
159
160
    /**
161
     * @param string[] $uniFares
162
     * @param string[] $negoFares
163
     */
164
    protected function loadMultiCorporate($uniFares, $negoFares)
165
    {
166
        if ($this->checkAnyNotEmpty($uniFares, $negoFares)) {
167
            $this->multiCorporate = new MultiCorporate($uniFares, $negoFares);
168
        }
169
    }
170
171
    /**
172
     * @param string|null $airline
173
     */
174
    protected function loadTransportInformation($airline)
175
    {
176
        if (!empty($airline)) {
177
            $this->transportInformation[] = new TransportInformation($airline);
178
        }
179
    }
180
181
    /**
182
     * @param string|null $origin
183
     * @param string|null $destination
184
     * @param \DateTime|null $travelDate
185
     */
186
    protected function loadTripDescription($origin, $destination, $travelDate)
187
    {
188
        if ($this->checkAnyNotEmpty($origin, $destination, $travelDate)) {
189
            $this->tripDescription[] = new TripDescription($origin, $destination, $travelDate);
190
        }
191
    }
192
}
193