Completed
Push — master ( f191f2...2cc3ee )
by Dieter
09:10
created

BaseMasterPricerMessage   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 14
c 0
b 0
f 0
lcom 3
cbo 6
dl 0
loc 101
ccs 55
cts 55
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A loadNumberOfUnits() 0 10 4
C loadPassenger() 0 31 7
B loadFareOptions() 0 24 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\Fare\MPPassenger;
26
use Amadeus\Client\RequestOptions\FareMasterPricerCalendarOptions;
27
use Amadeus\Client\RequestOptions\FareMasterPricerTbSearch;
28
use Amadeus\Client\RequestOptions\TicketCheckEligibilityOptions;
29
use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;
30
use Amadeus\Client\Struct\BaseWsMessage;
31
32
/**
33
 * BaseMasterPricerMessage
34
 *
35
 * @package Amadeus\Client\Struct\Fare
36
 * @author Dieter Devlieghere <[email protected]>
37
 */
38
class BaseMasterPricerMessage extends BaseWsMessage
39
{
40
    /**
41
     * Number of seats, recommendations.
42
     *
43
     * @var MasterPricer\NumberOfUnit
44
     */
45
    public $numberOfUnit;
46
47
    /**
48
     * Traveler Details
49
     *
50
     * @var MasterPricer\PaxReference[]
51
     */
52
    public $paxReference = [];
53
54
    /**
55
     * @var MasterPricer\FareOptions
56
     */
57
    public $fareOptions;
58
59
    /**
60
     * @param MPPassenger $passenger
61
     * @param int $counter BYREF
62
     * @param int $infantCounter BYREF
63
     */
64 148
    protected function loadPassenger($passenger, &$counter, &$infantCounter)
65
    {
66 148
        $isInfant = ($passenger->type === 'INF');
67
68 148
        $paxRef = new MasterPricer\PaxReference(
69 148
            $isInfant ? $infantCounter : $counter,
70 148
            $isInfant,
71 148
            $passenger->type
72 74
        );
73
74 148
        if ($isInfant) {
75 4
            $infantCounter++;
76 2
        } else {
77 148
            $counter++;
78
        }
79
80 148
        if ($passenger->count > 1) {
81 8
            for ($i = 2; $i <= $passenger->count; $i++) {
82 8
                $tmpCount = ($isInfant) ? $infantCounter : $counter;
83 8
                $paxRef->traveller[] = new MasterPricer\Traveller($tmpCount, $isInfant);
84
85 8
                if ($isInfant) {
86 4
                    $infantCounter++;
87 2
                } else {
88 8
                    $counter++;
89
                }
90 4
            }
91 4
        }
92
93 148
        $this->paxReference[] = $paxRef;
94 148
    }
95
96
    /**
97
     * @param FareMasterPricerTbSearch|FareMasterPricerCalendarOptions|TicketCheckEligibilityOptions $options
98
     * @return void
99
     */
100 164
    protected function loadNumberOfUnits($options)
101
    {
102 164
        if (is_int($options->nrOfRequestedPassengers) || is_int($options->nrOfRequestedResults) || $options->multiTicketWeights instanceof MultiTicketWeights) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 160 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
103 152
            $this->numberOfUnit = new MasterPricer\NumberOfUnit(
104 152
                $options->nrOfRequestedPassengers,
105 152
                $options->nrOfRequestedResults,
106 152
                $options->multiTicketWeights
107 76
            );
108 76
        }
109 164
    }
110
111
    /**
112
     * @param FareMasterPricerTbSearch|FareMasterPricerCalendarOptions|TicketCheckEligibilityOptions $options
113
     */
114 164
    protected function loadFareOptions($options)
115
    {
116 164
        if ($options->doTicketabilityPreCheck === true ||
117 160
            $this->checkAnyNotEmpty(
118 160
                $options->corporateCodesUnifares,
119 160
                $options->flightOptions,
120 160
                $options->currencyOverride,
121 160
                $options->feeIds,
122 160
                $options->multiTicket,
123 162
                $options->ticketingPriceScheme
124 80
            )
125 82
        ) {
126 48
            $this->fareOptions = new MasterPricer\FareOptions(
127 48
                $options->flightOptions,
128 48
                $options->corporateCodesUnifares,
129 48
                $options->doTicketabilityPreCheck,
130 48
                $options->currencyOverride,
131 48
                $options->feeIds,
132 48
                $options->corporateQualifier,
133 48
                $options->multiTicket,
134 48
                $options->ticketingPriceScheme
135 24
            );
136 24
        }
137 164
    }
138
}
139