Completed
Push — fopcreatefop ( 43117b...97f2d4 )
by Dieter
06:06
created

FopGroup::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
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\Fop;
24
25
use Amadeus\Client\RequestOptions\Fop\ElementRef;
26
use Amadeus\Client\RequestOptions\Fop\Group;
27
use Amadeus\Client\RequestOptions\Fop\ObFeeComputation;
28
use Amadeus\Client\RequestOptions\Fop\PaxRef;
29
30
/**
31
 * FopGroup
32
 *
33
 * @package Amadeus\Client\Struct\Fop
34
 * @author Dieter Devlieghere <[email protected]>
35
 */
36
class FopGroup
37
{
38
    /**
39
     * @var FopReference
40
     */
41
    public $fopReference;
42
    /**
43
     * @var PassengerAssociation[]
44
     */
45
    public $passengerAssociation = [];
46
    /**
47
     * @var PnrElementAssociation[]
48
     */
49
    public $pnrElementAssociation = [];
50
    /**
51
     * @var PricingTicketingDetails
52
     */
53
    public $pricingTicketingDetails;
54
    /**
55
     * @var FeeTypeInfo
56
     */
57
    public $feeTypeInfo;
58
    /**
59
     * @var FeeDetailsInfoGroup[]
60
     */
61
    public $feeDetailsInfoGroup = [];
62
    /**
63
     * @var FpProcessingOptions
64
     */
65
    public $fpProcessingOptions;
66
    /**
67
     * @var MopDescription[]
68
     */
69
    public $mopDescription = [];
70
71
    /**
72
     * FopGroup constructor.
73
     *
74
     * @param Group $options
75
     */
76
    public function __construct(Group $options)
77
    {
78
        $this->loadObFeeComp($options);
79
80
        $this->loadPaxElementRefs($options->paxRef, $options->elementRef);
81
82
        foreach ($options->mopInfo as $mopInfo) {
83
            $this->mopDescription[] = new MopDescription($mopInfo);
84
        }
85
    }
86
87
    /**
88
     * @param Group $options
89
     */
90
    protected function loadObFeeComp(Group $options)
91
    {
92
        if ($options->obFeeComputation instanceof ObFeeComputation) {
93
            $this->feeTypeInfo = new FeeTypeInfo(
94
                $options->obFeeComputation->option,
0 ignored issues
show
Unused Code introduced by
The call to FeeTypeInfo::__construct() has too many arguments starting with $options->obFeeComputation->option.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
95
                $options->obFeeComputation->optionInformation
96
            );
97
98
            $this->pricingTicketingDetails = new PricingTicketingDetails(
99
                $options->obFeeComputation->departureDate,
0 ignored issues
show
Unused Code introduced by
The call to PricingTicketingDetails::__construct() has too many arguments starting with $options->obFeeComputation->departureDate.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
100
                $options->obFeeComputation->city
101
            );
102
        }
103
    }
104
105
    /**
106
     * @param PaxRef[] $paxRef
107
     * @param ElementRef[] $elementRef
108
     */
109
    protected function loadPaxElementRefs($paxRef, $elementRef)
110
    {
111
        foreach ($paxRef as $singlePaxRef) {
112
            $this->passengerAssociation[] = new PassengerAssociation(
113
                $singlePaxRef->type,
114
                $singlePaxRef->value
115
            );
116
        }
117
118
        foreach ($elementRef as $singleElRef) {
119
            $this->pnrElementAssociation[] = new PnrElementAssociation(
120
                $singleElRef->type,
121
                $singleElRef->value
122
            );
123
        }
124
    }
125
}
126