Completed
Push — master ( e5baa0...e98dc1 )
by Dieter
07:25
created

TransferOwnership::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 18
rs 9.2
c 1
b 0
f 0
cc 4
eloc 9
nc 8
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\Pnr;
24
25
use Amadeus\Client\RequestOptions\PnrTransferOwnershipOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\Pnr\TransferOwnership\OaIdentificator;
28
use Amadeus\Client\Struct\Pnr\TransferOwnership\OfficeIdentification;
29
use Amadeus\Client\Struct\Pnr\TransferOwnership\PropagationAction;
30
use Amadeus\Client\Struct\Queue\RecordLocator;
31
32
/**
33
 * Structure class for representing the PNR_TransferOwnership request message
34
 *
35
 * @package Amadeus\Client\Struct\Pnr
36
 * @author Dieter Devlieghere <[email protected]>
37
 */
38
class TransferOwnership extends BaseWsMessage
39
{
40
    /**
41
     * @var RecordLocator
42
     */
43
    public $recordLocator;
44
45
    /**
46
     * @var TransferOwnership\PropagationAction
47
     */
48
    public $propagatioAction;
49
50
    /**
51
     * @var TransferOwnership\OfficeIdentification
52
     */
53
    public $officeIdentification;
54
55
    /**
56
     * @var TransferOwnership\OaIdentificator
57
     */
58
    public $oaIdentificator;
59
60
    /**
61
     * TransferOwnership constructor.
62
     *
63
     * @param PnrTransferOwnershipOptions $options
64
     */
65
    public function __construct($options)
66
    {
67
        if (!empty($options->recordLocator)) {
68
            $this->recordLocator = new RecordLocator($options->recordLocator);
69
        }
70
71
        if ($options->inhibitPropagation === true) {
72
            $this->propagatioAction = new PropagationAction(
73
                PropagationAction::PROPAGATION_INHIBIT
74
            );
75
        }
76
77
        $this->loadNewOffice($options);
78
79
        if (!empty($options->newThirdParty)) {
80
            $this->oaIdentificator = new OaIdentificator($options->newThirdParty);
81
        }
82
    }
83
84
    /**
85
     * @param PnrTransferOwnershipOptions $options
86
     */
87
    protected function loadNewOffice($options)
88
    {
89
        if (!empty($options->newOffice) || !empty($options->newUserSecurityEntity)) {
90
            $this->officeIdentification = new OfficeIdentification(
91
                $options->newOffice,
92
                $options->newUserSecurityEntity
93
            );
94
95
            if ($this->checkAnyTrue(
96
                $options->changeQueueingOffice,
97
                $options->changeTicketingOffice,
98
                $options->changeOptionQueueElement
99
            )) {
100
                $this->officeIdentification->loadSpecificChanges(
101
                    $options->changeTicketingOffice,
102
                    $options->changeQueueingOffice,
103
                    $options->changeOptionQueueElement
104
                );
105
            }
106
        }
107
    }
108
}
109