Passed
Pull Request — master (#324)
by
unknown
04:14
created

TravelProductInformation::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 10
cts 10
cp 1
rs 9.584
c 0
b 0
f 0
cc 2
nc 2
nop 10
crap 2

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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;
24
25
/**
26
 * TravelProductInformation
27
 *
28
 * @package Amadeus\Client\Struct\Air
29
 * @author dieter <[email protected]>
30
 */
31
class TravelProductInformation
32
{
33
    /**
34
     * @var FlightDate
35
     */
36
    public $flightDate;
37
    /**
38
     * @var PointDetails
39
     */
40
    public $boardPointDetails;
41
    /**
42
     * @var PointDetails
43
     */
44
    public $offpointDetails;
45
    /**
46
     * @var CompanyDetails
47
     */
48
    public $companyDetails;
49
    /**
50
     * @var FlightIdentification
51
     */
52
    public $flightIdentification;
53
    /**
54
     * @var FlightTypeDetails
55
     */
56
    public $flightTypeDetails;
57
    /**
58
     * 700 Request is expanded to exclude connection point(s)
59
     * 701 Request is expanded to exclude carriers
60
     * 702 Before connection
61
     * 703 After connection
62
     * 704 Board point used as airport code only
63
     * 705 Off point used as airport code only
64
     * 706 Board point and off point used as airport code only
65
     * 7SR Stateless/refugee/etc
66
     * 7TR Transit visa
67
     * ACK Acknowledgment
68
     * AF All flights to be processed
69
     * AI Additional information
70
     * AT Alternate flight
71
     * B Boarding pass may not be issued until the mutually agreed time period.
72
     * BS Blind sell
73
     * C Contact information
74
     * CD Change of date
75
     * CM1 Change date minus 1 day
76
     * CN Cascading not allowed
77
     * CP2 Change date plus 2 days
78
     * CY Cascading allowed
79
     * DP Diplomatic
80
     * EC Excess bags charged
81
     * EI Excess bags identified
82
     * EW Excess bags waived
83
     * F Form of payment details
84
     * FA First available
85
     * FE Bagtag issuance required by querying system
86
     * FN No, seat request not fulfilled
87
     * FT Fare/tax/total details
88
     * FY Yes, seat request fulfilled
89
     * GC Green card/alien resident permit
90
     * HP Head of Baggage Pool
91
     * J Action based on journey
92
     * MH Bagtag issuance required by responding system
93
     * MI Military ID
94
     * MP Member of Baggage Pool
95
     * MPP Multi passenger passport
96
     * N No action required
97
     * NB No a boarding pass may not be issued
98
     * NP Not pooled
99
     * NS Requested city pair, no seat data applies
100
     * P Action required
101
     * PC Purchaser ticketing restriction/conditions
102
     * PI Partial passenger indicator
103
     * PP Partial passenger/partial segment indicator
104
     * PS Partial segment indicator
105
     * PT Passport
106
     * R Routing information
107
     * RD Reservations details
108
     * SA Seat assignment association - desires seating together
109
     * SS Seaman/ Sailor
110
     * T Total amount collected
111
     * TF This flight only to be processed
112
     * TP Action required and candidate for special Yield Management processing
113
     * VI Visa
114
     * Y Yes a boarding pass may be issued
115
     * YP Pooled
116
     *
117
     * @var string
118
     */
119
    public $specialSegment;
120
    /**
121
     * @var MarriageDetails
122
     */
123
    public $marriageDetails;
124
125
    /**
126
     * TravelProductInformation constructor.
127
     *
128
     * @param \DateTime $departureDate
129
     * @param string $from
130
     * @param string $to
131
     * @param string $company
132
     * @param string $flightNumber
133
     * @param string $bookingClass
134
     * @param \DateTime|null $arrivalDate
135
     * @param string|\DateTime|null $arrivalTime
136
     * @param int|null $dateVariation
137
     * @param string|null $flightTypeDetails
138
     */
139 65
    public function __construct(
140
        $departureDate,
141
        $from,
142
        $to,
143
        $company,
144
        $flightNumber,
145
        $bookingClass,
146
        $arrivalDate = null,
147
        $arrivalTime = null,
148
        $dateVariation = null,
149
        $flightTypeDetails = null
150
    ) {
151 65
        $this->flightDate = $this->parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation);
152 65
        $this->boardPointDetails = new PointDetails($from);
153 65
        $this->offpointDetails = new PointDetails($to);
154 65
        $this->companyDetails = new CompanyDetails($company);
155 65
        $this->flightIdentification = new FlightIdentification($flightNumber, $bookingClass);
156 65
        if (!is_null($flightTypeDetails)) {
157 5
            $this->flightTypeDetails = new FlightTypeDetails($flightTypeDetails);
158 2
        }
159 65
    }
160
161
    protected function parseFlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation)
162
    {
163
        return new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation);
164
    }
165
}
166