Completed
Push — develop ( 79a83d...d8326f )
by Dieter
05:21
created

InformativePricingWithoutPNR13   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 6

Importance

Changes 0
Metric Value
wmc 7
lcom 3
cbo 6
dl 0
loc 71
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A loadPassengers() 0 9 2
A loadSegments() 0 6 2
A loadPricingOptions() 0 7 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\Fare;
24
25
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Passenger;
28
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Segment;
29
use Amadeus\Client\RequestOptions\FareInformativePricingWithoutPnrOptions;
30
use Amadeus\Client\Struct\Fare\InformativePricing13\OriginatorGroup;
31
use Amadeus\Client\Struct\Fare\InformativePricing13\PassengersGroup;
32
use Amadeus\Client\Struct\Fare\InformativePricing13\SegmentGroup;
33
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup;
34
35
/**
36
 * InformativePricingWithoutPNR
37
 *
38
 * @package Amadeus\Client\Struct\Fare
39
 * @author Dieter Devlieghere <[email protected]>
40
 */
41
class InformativePricingWithoutPNR13 extends BaseWsMessage
42
{
43
    /**
44
     * @var OriginatorGroup
45
     */
46
    public $originatorGroup;
47
48
    /**
49
     * @var PassengersGroup[]
50
     */
51
    public $passengersGroup = [];
52
53
    /**
54
     * @var SegmentGroup[]
55
     */
56
    public $segmentGroup = [];
57
58
    /**
59
     * @var PricingOptionGroup[]
60
     */
61
    public $pricingOptionGroup = [];
62
63
    /**
64
     * InformativePricingWithoutPNR13 constructor.
65
     *
66
     * @param FareInformativePricingWithoutPnrOptions $options
67
     */
68
    public function __construct(FareInformativePricingWithoutPnrOptions $options)
69
    {
70
        $this->loadPassengers($options->passengers);
71
72
        $this->loadSegments($options->segments);
73
74
        $this->loadPricingOptions($options->pricingOptions);
75
76
    }
77
78
    /**
79
     * @param Passenger[] $passengers
80
     */
81
    protected function loadPassengers($passengers)
82
    {
83
        $counter = 1;
84
85
        foreach ($passengers as $passenger) {
86
            $this->passengersGroup[] = new PassengersGroup($passenger, $counter);
87
            $counter++;
88
        }
89
    }
90
91
    /**
92
     * @param Segment[] $segments
93
     */
94
    protected function loadSegments($segments)
95
    {
96
        foreach ($segments as $segment) {
97
            $this->segmentGroup[] = new SegmentGroup($segment);
98
        }
99
    }
100
101
    /**
102
     * @param PricingOptions|null $pricingOptions
103
     */
104
    protected function loadPricingOptions($pricingOptions)
105
    {
106
        if (!($pricingOptions instanceof PricingOptions)) {
107
            $pricingOptions = new PricingOptions();
108
        }
109
        $this->pricingOptionGroup = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions);
110
    }
111
}
112