Completed
Push — develop ( a8951f...6805ee )
by Dieter
05:48
created

MultiAvailability   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
lcom 1
cbo 7
dl 0
loc 67
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 3
A loadOptionalParams() 0 19 4
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\Air;
24
25
use Amadeus\Client\RequestOptions\Air\MultiAvailability\FrequentTraveller as FrequentTravellerOptions;
26
use Amadeus\Client\RequestOptions\AirMultiAvailabilityOptions;
27
use Amadeus\Client\Struct\Air\MultiAvailability\ConsumerReferenceInformation;
28
use Amadeus\Client\Struct\Air\MultiAvailability\FrequentTraveller;
29
use Amadeus\Client\Struct\Air\MultiAvailability\PointOfCommencement;
30
use Amadeus\Client\Struct\Air\MultiAvailability\RequestSection;
31
use Amadeus\Client\Struct\BaseWsMessage;
32
33
/**
34
 * MultiAvailability
35
 *
36
 * @package Amadeus\Client\Struct\Air
37
 * @author Dieter Devlieghere <[email protected]>
38
 */
39
class MultiAvailability extends BaseWsMessage
40
{
41
    /**
42
     * @var MultiAvailability\MessageActionDetails
43
     */
44
    public $messageActionDetails;
45
    /**
46
     * @var MultiAvailability\ConsumerReferenceInformation
47
     */
48
    public $consumerReferenceInformation;
49
    /**
50
     * @var MultiAvailability\PointOfCommencement
51
     */
52
    public $pointOfCommencement;
53
    /**
54
     * @var MultiAvailability\FrequentTraveller
55
     */
56
    public $frequentTraveller;
57
    /**
58
     * @var MultiAvailability\RequestSection[]
59
     */
60
    public $requestSection = [];
61
62
    /**
63
     * MultiAvailability constructor.
64
     *
65
     * @param AirMultiAvailabilityOptions $params
66
     */
67
    public function __construct(AirMultiAvailabilityOptions $params)
68
    {
69
        $this->messageActionDetails = new MultiAvailability\MessageActionDetails(
70
            $params->actionCode,
71
            $params->businessFunction
72
        );
73
74
        if (count($params->requestOptions) > 0) {
75
            foreach ($params->requestOptions as $requestOption) {
76
                $this->requestSection[] = new RequestSection($requestOption);
77
            }
78
        }
79
80
        $this->loadOptionalParams($params);
81
    }
82
83
    /**
84
     * @param AirMultiAvailabilityOptions $params
85
     */
86
    protected function loadOptionalParams($params)
87
    {
88
        if (!empty($params->commencementPoint)) {
89
            $this->pointOfCommencement = new PointOfCommencement(
90
                $params->commencementPoint,
91
                $params->commencementDate
92
            );
93
        }
94
95
        if (!empty($params->corporationNumber)) {
96
            $this->consumerReferenceInformation = new ConsumerReferenceInformation(
97
                $params->corporationNumber
98
            );
99
        }
100
101
        if ($params->frequentTraveller instanceof FrequentTravellerOptions) {
102
            $this->frequentTraveller = new FrequentTraveller($params->frequentTraveller);
103
        }
104
    }
105
}
106