Completed
Pull Request — master (#324)
by
unknown
07:34
created

TravelResponseDetails::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2.032

Importance

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

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\Fare\MasterPricer;
24
25
use Amadeus\Client\Struct\Air\PointDetails;
26
use Amadeus\Client\Struct\Air\CompanyDetails;
27
use Amadeus\Client\Struct\Air\FlightIdentification;
28
use Amadeus\Client\Struct\Air\FlightTypeDetails;
29
30
/**
31
 * TravelResponseDetails
32
 *
33
 * @package Amadeus\Client\Struct\Fare\MasterPricer
34
 * @author Mike Hernas <[email protected]>
35
 */
36 View Code Duplication
class TravelResponseDetails
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
{
38
39
    /**
40
     * @var FlightDate
41
     */
42
    public $flightDate;
43
    /**
44
     * @var PointDetails
45
     */
46
    public $boardPointDetails;
47
    /**
48
     * @var PointDetails
49
     */
50
    public $offpointDetails;
51
    /**
52
     * @var CompanyDetails
53
     */
54
    public $companyDetails;
55
    /**
56
     * @var FlightIdentification
57
     */
58
    public $flightIdentification;
59
    /**
60
     * @var FlightTypeDetails
61
     */
62
    public $flightTypeDetails;
63
64
    /**
65
     * TravelProductInformation constructor.
66
     *
67
     * @param \DateTime $departureDate
68
     * @param string $from
69
     * @param string $to
70
     * @param string $company
71
     * @param string $flightNumber
72
     * @param string $bookingClass
73
     * @param \DateTime|null $arrivalDate
74
     * @param string|\DateTime|null $arrivalTime
75
     * @param int|null $dateVariation
76
     * @param string|null $flightTypeDetails
77
     */
78 4
    public function __construct(
79
        $departureDate,
80
        $from,
81
        $to,
82
        $company,
83
        $flightNumber,
84
        $bookingClass,
85
        $arrivalDate = null,
86
        $arrivalTime = null,
87
        $dateVariation = null,
88
        $flightTypeDetails = null
89
    ) {
90 4
        $this->flightDate = new FlightDate($departureDate, $arrivalDate, $arrivalTime, $dateVariation);
91 4
        $this->boardPointDetails = new PointDetails($from);
92 4
        $this->offpointDetails = new PointDetails($to);
93 4
        $this->companyDetails = new CompanyDetails($company);
94 4
        $this->flightIdentification = new FlightIdentification($flightNumber, $bookingClass);
95 4
        if (!is_null($flightTypeDetails)) {
96
            $this->flightTypeDetails = new FlightTypeDetails($flightTypeDetails);
97
        }
98 4
    }
99
}
100