Completed
Pull Request — master (#220)
by Dieter
18:46 queued 10:46
created

StandaloneCatalogue::loadPassengers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
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
namespace Amadeus\Client\Struct\Service;
23
24
use Amadeus\Client\Struct\BaseWsMessage;
25
use Amadeus\Client\Struct\Service\StandaloneCatalogue\PassengerInfoGroup;
26
use Amadeus\Client\Struct\Service\StandaloneCatalogue\FlightInfo;
27
use Amadeus\Client\Struct\Fare\PricePNRWithBookingClass13;
28
29
/**
30
 * StandaloneCatalogue
31
 *
32
 * @package Amadeus\Client\Struct\Fare
33
 * @author Arvind Pandey <[email protected]>
34
 */
35
class StandaloneCatalogue extends BaseWsMessage
36
{
37
38
    /**
39
     *
40
     * @var passengerInfoGroup[]
41
     */
42
    public $passengerInfoGroup = [];
43
44
    /**
45
     *
46
     * @var flightInfo[]
47
     */
48
    public $flightInfo = [];
49
50
    /**
51
     *
52
     * @var pricingOption[]
53
     */
54
    public $pricingOption = [];
55
56
    /**
57
     * StandaloneCatalogue constructor.
58
     *
59
     * @param ServiceStandaloneCatalogueOptions|null $options
60
     */
61 View Code Duplication
    public function __construct($options)
0 ignored issues
show
Duplication introduced by
This method 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...
62
    {
63
        if (! is_null($options)) {
64
            $this->loadPassengers($options->passengers);
65
            
66
            $this->loadflightDetails($options->segments);
67
            
68
            $this->loadPricingOptions($options->pricingOptions);
69
        }
70
    }
71
72
    /**
73
     *
74
     * @param Passenger[] $passengers
75
     */
76
    protected function loadPassengers($passengers)
77
    {
78
        $counter = 1;
79
        foreach ($passengers as $passenger) {
80
            $this->passengerInfoGroup[] = new PassengerInfoGroup($passenger, $counter);
81
            $counter ++;
82
        }
83
    }
84
85
    /**
86
     *
87
     * @param Segment[] $segments
88
     */
89
    protected function loadflightDetails($segments)
90
    {
91
        foreach ($segments as $segment) {
92
            $this->flightInfo[] = new FlightInfo($segment);
93
        }
94
    }
95
96
    /**
97
     *
98
     * @param PricingOptions|null $pricingOptions
99
     */
100
    protected function loadPricingOptions($pricingOptions)
101
    {
102
        $this->pricingOption = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions);
0 ignored issues
show
Bug introduced by
It seems like $pricingOptions defined by parameter $pricingOptions on line 100 can also be of type null; however, Amadeus\Client\Struct\Fa...onsFromRequestOptions() does only seem to accept object<Amadeus\Client\Re...ithBookingClassOptions>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Documentation Bug introduced by
It seems like \Amadeus\Client\Struct\F...ptions($pricingOptions) of type array<integer,object<Ama...13\PricingOptionGroup>> is incompatible with the declared type array<integer,object<Ama...Service\pricingOption>> of property $pricingOption.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
103
    }
104
}
105