Completed
Push — develop ( b71e24...13e4b5 )
by Dieter
10:39
created

DisplayQueryReport   C

Complexity

Total Complexity 32

Size/Duplication

Total Lines 220
Duplicated Lines 0 %

Coupling/Cohesion

Components 11
Dependencies 13

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 32
lcom 11
cbo 13
dl 0
loc 220
rs 5.9999
c 1
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 28 1
A loadRequestOptions() 0 6 2
A loadAgencySource() 0 6 4
A loadAgent() 0 6 2
A loadTransaction() 0 6 4
A loadValidatingCarrier() 0 6 2
A loadDateRange() 0 6 3
A loadDate() 0 6 3
A loadCurrency() 0 6 3
A loadFormOfPayment() 0 6 3
A loadSalesIndicator() 0 6 2
A loadScrolling() 0 6 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\SalesReports;
24
25
use Amadeus\Client\RequestOptions\SalesReportsDisplayQueryReportOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\ActionDetails;
28
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\AgencyDetails;
29
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\AgentUserDetails;
30
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\CurrencyInfo;
31
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\DateDetails;
32
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\FormOfPaymentDetails;
33
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\RequestOption;
34
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\SalesIndicator;
35
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\SalesPeriodDetails;
36
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\TransactionData;
37
use Amadeus\Client\Struct\SalesReports\DisplayQueryReport\ValidatingCarrierDetails;
38
39
/**
40
 * DisplayQueryReport
41
 *
42
 * @package Amadeus\Client\Struct\SalesReports
43
 * @author Dieter Devlieghere <[email protected]>
44
 */
45
class DisplayQueryReport extends BaseWsMessage
46
{
47
    /**
48
     * @var DisplayQueryReport\ActionDetails
49
     */
50
    public $actionDetails;
51
52
    /**
53
     * @var DisplayQueryReport\AgentUserDetails
54
     */
55
    public $agentUserDetails;
56
57
    /**
58
     * @var DisplayQueryReport\DateDetails
59
     */
60
    public $dateDetails;
61
62
    /**
63
     * @var DisplayQueryReport\CurrencyInfo
64
     */
65
    public $currencyInfo;
66
67
    /**
68
     * @var DisplayQueryReport\AgencyDetails
69
     */
70
    public $agencyDetails;
71
72
    /**
73
     * @var DisplayQueryReport\SalesPeriodDetails
74
     */
75
    public $salesPeriodDetails;
76
77
    /**
78
     * @var DisplayQueryReport\TransactionData[]
79
     */
80
    public $transactionData = [];
81
82
    /**
83
     * @var DisplayQueryReport\FormOfPaymentDetails
84
     */
85
    public $formOfPaymentDetails;
86
87
    /**
88
     * @var DisplayQueryReport\ValidatingCarrierDetails
89
     */
90
    public $validatingCarrierDetails;
91
92
    /**
93
     * @var DisplayQueryReport\RequestOption
94
     */
95
    public $requestOption;
96
97
    /**
98
     * @var DisplayQueryReport\SalesIndicator
99
     */
100
    public $salesIndicator;
101
102
    /**
103
     * @var DisplayQueryReport\FromSequenceDocumentNumber
104
     */
105
    public $fromSequenceDocumentNumber;
106
107
    /**
108
     * @var DisplayQueryReport\AttributeInfo
109
     */
110
    public $attributeInfo;
111
112
    /**
113
     * DisplayQueryReport constructor.
114
     *
115
     * @param SalesReportsDisplayQueryReportOptions $options
116
     */
117
    public function __construct(SalesReportsDisplayQueryReportOptions $options)
118
    {
119
        $this->loadRequestOptions($options->requestOptions);
120
121
        $this->loadAgencySource($options->agencySourceType, $options->agencyIataNumber, $options->agencyOfficeId);
122
123
        $this->loadAgent($options->agentCode);
124
125
        $this->loadTransaction(
126
            $options->transactionCode,
127
            $options->transactionType,
128
            $options->transactionIssueIndicator
129
        );
130
131
        $this->loadValidatingCarrier($options->validatingCarrier);
132
133
        $this->loadDateRange($options->startDate, $options->endDate);
134
135
        $this->loadDate($options->specificDateType, $options->specificDate);
136
137
        $this->loadCurrency($options->currencyType, $options->currency);
138
139
        $this->loadFormOfPayment($options->fopType, $options->fopVendor);
140
141
        $this->loadSalesIndicator($options->salesIndicator);
142
143
        $this->loadScrolling($options->scrollingCount, $options->scrollingFromItem);
144
    }
145
146
    /**
147
     * @param array|null $requestOptions
148
     */
149
    protected function loadRequestOptions($requestOptions)
150
    {
151
        if (!empty($requestOptions)) {
152
            $this->requestOption = new RequestOption($requestOptions);
153
        }
154
    }
155
156
    /**
157
     * @param string|null $agencySourceType
158
     * @param string|null $iataNumber
159
     * @param string|null $officeId
160
     */
161
    protected function loadAgencySource($agencySourceType, $iataNumber, $officeId)
162
    {
163
        if (!empty($agencySourceType) || !empty($iataNumber) || !empty($officeId)) {
164
            $this->agencyDetails = new AgencyDetails($agencySourceType, $iataNumber, $officeId);
165
        }
166
    }
167
168
    /**
169
     * @param string|null $agentCode
170
     */
171
    protected function loadAgent($agentCode)
172
    {
173
        if (!empty($agentCode)) {
174
            $this->agentUserDetails = new AgentUserDetails($agentCode);
175
        }
176
    }
177
178
    /**
179
     * @param string|null $code
180
     * @param string|null $type
181
     * @param string|null $issueIndicator
182
     */
183
    protected function loadTransaction($code, $type, $issueIndicator)
184
    {
185
        if (!empty($type) || !empty($code) || !empty($issueIndicator)) {
186
            $this->transactionData[] = new TransactionData($type, $code, $issueIndicator);
187
        }
188
    }
189
190
    /**
191
     * @param string|null $validatingCarrier
192
     */
193
    protected function loadValidatingCarrier($validatingCarrier)
194
    {
195
        if (!empty($validatingCarrier)) {
196
            $this->validatingCarrierDetails = new ValidatingCarrierDetails($validatingCarrier);
197
        }
198
    }
199
200
    /**
201
     * @param \DateTime|null $startDate
202
     * @param \DateTime|null $endDate
203
     */
204
    protected function loadDateRange($startDate, $endDate)
205
    {
206
        if (!empty($startDate) || !empty($endDate)) {
207
            $this->salesPeriodDetails = new SalesPeriodDetails($startDate, $endDate);
208
        }
209
    }
210
211
    /**
212
     * @param string|null $type
213
     * @param \DateTime|null $date
214
     */
215
    protected function loadDate($type, $date)
216
    {
217
        if (!empty($type) || !empty($date)) {
218
            $this->dateDetails = new DateDetails($type, $date);
0 ignored issues
show
Bug introduced by
It seems like $date defined by parameter $date on line 215 can be null; however, Amadeus\Client\Struct\Sa...eDetails::__construct() does not accept null, maybe add an additional type check?

It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.

We recommend to add an additional type check (or disallow null for the parameter):

function notNullable(stdClass $x) { }

// Unsafe
function withoutCheck(stdClass $x = null) {
    notNullable($x);
}

// Safe - Alternative 1: Adding Additional Type-Check
function withCheck(stdClass $x = null) {
    if ($x instanceof stdClass) {
        notNullable($x);
    }
}

// Safe - Alternative 2: Changing Parameter
function withNonNullableParam(stdClass $x) {
    notNullable($x);
}
Loading history...
219
        }
220
    }
221
222
    /**
223
     * @param string $type
224
     * @param string $currency
225
     */
226
    protected function loadCurrency($type, $currency)
227
    {
228
        if (!empty($type) || !empty($currency)) {
229
            $this->currencyInfo = new CurrencyInfo($type, $currency);
230
        }
231
    }
232
233
    /**
234
     * @param string $type
235
     * @param string $vendor
236
     */
237
    protected function loadFormOfPayment($type, $vendor)
238
    {
239
        if (!empty($type) || !empty($vendor)) {
240
            $this->formOfPaymentDetails = new FormOfPaymentDetails($type, $vendor);
241
        }
242
    }
243
244
    /**
245
     * @param string $indicator
246
     */
247
    protected function loadSalesIndicator($indicator)
248
    {
249
        if (!empty($indicator)) {
250
            $this->salesIndicator = new SalesIndicator($indicator);
251
        }
252
    }
253
254
    /**
255
     * @param int $count
256
     * @param string $fromItem
257
     */
258
    protected function loadScrolling($count, $fromItem)
259
    {
260
        if (!empty($count) || !empty($fromItem)) {
261
            $this->actionDetails = new ActionDetails($count, $fromItem);
262
        }
263
    }
264
}
265