Completed
Pull Request — master (#43)
by Dieter
13:45
created

FopGroup::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2
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 14
    public function __construct(Group $options)
77
    {
78 14
        $this->loadObFeeComp($options);
79
80 14
        $this->loadPaxElementRefs($options->paxRef, $options->elementRef);
81
82 14
        foreach ($options->mopInfo as $mopInfo) {
83 14
            $this->mopDescription[] = new MopDescription($mopInfo);
84 14
        }
85 14
    }
86
87
    /**
88
     * @param Group $options
89
     */
90 14
    protected function loadObFeeComp(Group $options)
91
    {
92 14
        if ($options->obFeeComputation instanceof ObFeeComputation) {
93 1
            $this->feeTypeInfo = new FeeTypeInfo(
94 1
                $options->obFeeComputation->option,
95 1
                $options->obFeeComputation->optionInformation
96 1
            );
97
98 1
            $this->pricingTicketingDetails = new PricingTicketingDetails(
99 1
                $options->obFeeComputation->departureDate,
100 1
                $options->obFeeComputation->city
101 1
            );
102 1
        }
103 14
    }
104
105
    /**
106
     * @param PaxRef[] $paxRef
107
     * @param ElementRef[] $elementRef
108
     */
109 14
    protected function loadPaxElementRefs($paxRef, $elementRef)
110
    {
111 14
        foreach ($paxRef as $singlePaxRef) {
112 3
            $this->passengerAssociation[] = new PassengerAssociation(
113 3
                $singlePaxRef->type,
114 3
                $singlePaxRef->value
115 3
            );
116 14
        }
117
118 14
        foreach ($elementRef as $singleElRef) {
119 11
            $this->pnrElementAssociation[] = new PnrElementAssociation(
120 11
                $singleElRef->type,
121 11
                $singleElRef->value
122 11
            );
123 14
        }
124 14
    }
125
}
126