Completed
Push — master ( d76d99...0fe829 )
by Dieter
07:42
created

Pnr   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createPNRRetrieve() 0 9 1
A createPNRRetrieveAndDisplay() 0 9 1
A createPNRAddMultiElements() 0 11 3
A createPNRCancel() 0 4 1
A createPNRDisplayHistory() 0 4 1
A createPNRTransferOwnership() 0 4 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\RequestCreator;
24
25
use Amadeus\Client\Params\RequestCreatorParams;
26
use Amadeus\Client\RequestOptions\PnrAddMultiElementsBase;
27
use Amadeus\Client\RequestOptions\PnrCancelOptions;
28
use Amadeus\Client\RequestOptions\PnrCreatePnrOptions;
29
use Amadeus\Client\RequestOptions\PnrDisplayHistoryOptions;
30
use Amadeus\Client\RequestOptions\PnrRetrieveAndDisplayOptions;
31
use Amadeus\Client\RequestOptions\PnrRetrieveOptions;
32
use Amadeus\Client\RequestOptions\PnrTransferOwnershipOptions;
33
use Amadeus\Client\Struct;
34
35
/**
36
 * PNR Request Creator
37
 *
38
 * Responsible for creating all "Pnr_" messages
39
 *
40
 * methods for creation must have the correct name
41
 * 'create'<message name without underscores>
42
 *
43
 * @package Amadeus\Client\RequestCreator
44
 * @author Dieter Devlieghere <[email protected]>
45
 */
46
class Pnr
47
{
48
    /**
49
     * @var RequestCreatorParams
50
     */
51
    protected $params;
52
53
    /**
54
     * Pnr constructor.
55
     * @param RequestCreatorParams $params
56
     */
57
    public function __construct(RequestCreatorParams $params)
58
    {
59
        $this->params = $params;
60
    }
61
62
    /**
63
     * Create request object for PNR_Retrieve message
64
     *
65
     * @param PnrRetrieveOptions $params
66
     * @return Struct\Pnr\Retrieve
67
     */
68
    public function createPNRRetrieve(PnrRetrieveOptions $params)
69
    {
70
        $retrieveRequest = new Struct\Pnr\Retrieve(
71
            Struct\Pnr\Retrieve::RETR_TYPE_BY_RECLOC,
72
            $params->recordLocator
73
        );
74
75
        return $retrieveRequest;
76
    }
77
78
    /**
79
     * @param PnrRetrieveAndDisplayOptions $params
80
     * @return Struct\Pnr\RetrieveAndDisplay
81
     */
82
    public function createPNRRetrieveAndDisplay(PnrRetrieveAndDisplayOptions $params)
83
    {
84
        $req = new Struct\Pnr\RetrieveAndDisplay(
85
            $params->recordLocator,
86
            $params->retrieveOption
87
        );
88
89
        return $req;
90
    }
91
92
    /**
93
     * @param PnrAddMultiElementsBase $params
94
     * @return Struct\Pnr\AddMultiElements
95
     */
96
    public function createPNRAddMultiElements(PnrAddMultiElementsBase $params)
97
    {
98
        if ($params instanceof PnrCreatePnrOptions && empty($params->receivedFrom)) {
99
            //Automagically add RF if not present:
100
            $params->receivedFrom = $this->params->receivedFrom;
101
        }
102
103
        $req = new Struct\Pnr\AddMultiElements($params);
104
105
        return $req;
106
    }
107
108
    /**
109
     * @param PnrCancelOptions $params
110
     * @return Struct\Pnr\Cancel
111
     */
112
    public function createPNRCancel(PnrCancelOptions $params)
113
    {
114
        return new Struct\Pnr\Cancel($params);
115
    }
116
117
    /**
118
     * @param PnrDisplayHistoryOptions $params
119
     * @return Struct\Pnr\DisplayHistory
120
     */
121
    public function createPNRDisplayHistory(PnrDisplayHistoryOptions $params)
122
    {
123
        return new Struct\Pnr\DisplayHistory($params);
124
    }
125
126
    /**
127
     * @param PnrTransferOwnershipOptions $params
128
     * @return Struct\Pnr\TransferOwnership
129
     */
130
    public function createPNRTransferOwnership(PnrTransferOwnershipOptions $params)
131
    {
132
        return new Struct\Pnr\TransferOwnership($params);
133
    }
134
}
135