Completed
Pull Request — master (#220)
by
unknown
10:38 queued 43s
created

StandaloneCatalogue::loadflightDetails()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
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\RequestOptions\Service\StandaloneCatalogue\Passenger;
26
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Segment;
27
use Amadeus\Client\RequestOptions\Service\StandaloneCatalogue\ServiceStandalonePricingOptions;
28
use Amadeus\Client\RequestOptions\ServiceIntegratedPricingOptions;
29
use Amadeus\Client\RequestOptions\ServiceStandaloneCatalogueOptions;
30
use Amadeus\Client\Struct\Service\StandaloneCatalogue\PassengerInfoGroup;
31
use Amadeus\Client\Struct\Service\StandaloneCatalogue\FlightInfo;
32
use Amadeus\Client\Struct\Fare\PricePNRWithBookingClass13;
33
34
/**
35
 * StandaloneCatalogue
36
 *
37
 * @package Amadeus\Client\Struct\Fare
38
 * @author Arvind Pandey <[email protected]>
39
 */
40
class StandaloneCatalogue extends BaseWsMessage
41
{
42
43
    /**
44
     *
45
     * @var passengerInfoGroup[]
46
     */
47
    public $passengerInfoGroup = [];
48
49
    /**
50
     *
51
     * @var flightInfo[]
52
     */
53
    public $flightInfo = [];
54
55
    /**
56
     *
57
     * @var pricingOption[]
58
     */
59
    public $pricingOption = [];
60
61
    /**
62
     * StandaloneCatalogue constructor.
63
     *
64
     * @param ServiceStandaloneCatalogueOptions|null $options
65
     */
66 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...
67
    {
68
        if (! is_null($options)) {
69
            $this->loadPassengers($options->passengers);
0 ignored issues
show
Documentation introduced by
$options->passengers is of type array<integer,object<Ama...tivePricing\Passenger>>, but the function expects a array<integer,object<Ama...neCatalogue\Passenger>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
            
71
            $this->loadflightDetails($options->segments);
72
            
73
            $this->loadPricingOptions($options->pricingOptions);
0 ignored issues
show
Documentation introduced by
$options->pricingOptions is of type object<Amadeus\Client\Re...Pricing\PricingOptions>, but the function expects a object<Amadeus\Client\St...ce\PricingOptions>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74
        }
75
    }
76
77
    /**
78
     *
79
     * @param Passenger[] $passengers
80
     */
81
    protected function loadPassengers($passengers)
82
    {
83
        $counter = 1;
84
        foreach ($passengers as $passenger) {
85
            $this->passengerInfoGroup[] = new PassengerInfoGroup($passenger, $counter);
0 ignored issues
show
Documentation introduced by
$passenger is of type object<Amadeus\Client\Re...oneCatalogue\Passenger>, but the function expects a object<Amadeus\Client\St...oneCatalogue\Passenger>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
86
            $counter ++;
87
        }
88
    }
89
90
    /**
91
     *
92
     * @param Segment[] $segments
93
     */
94
    protected function loadflightDetails($segments)
95
    {
96
        foreach ($segments as $segment) {
97
            $this->flightInfo[] = new FlightInfo($segment);
0 ignored issues
show
Documentation introduced by
$segment is of type object<Amadeus\Client\Re...rmativePricing\Segment>, but the function expects a object<Amadeus\Client\St...neCatalogue\FlightInfo>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
98
        }
99
    }
100
101
    /**
102
     *
103
     * @param PricingOptions|null $pricingOptions
104
     */
105
    protected function loadPricingOptions($pricingOptions)
106
    {
107
        $this->pricingOption = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions);
0 ignored issues
show
Bug introduced by
It seems like $pricingOptions defined by parameter $pricingOptions on line 105 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...
108
    }
109
}
110