Completed
Push — master ( 2bb369...448aae )
by Dieter
05:42
created

DeleteTST::__construct()   B

Complexity

Conditions 6
Paths 17

Size

Total Lines 49
Code Lines 28

Duplication

Lines 26
Ratio 53.06 %

Importance

Changes 0
Metric Value
dl 26
loc 49
rs 8.5906
c 0
b 0
f 0
cc 6
eloc 28
nc 17
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\Ticket;
24
25
use Amadeus\Client\RequestOptions\TicketDeleteTstOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
28
/**
29
 * Ticket_DeleteTST
30
 *
31
 * @package Amadeus\Client\Struct\Ticket
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class DeleteTST extends BaseWsMessage
35
{
36
    /**
37
     * @var DeleteMode
38
     */
39
    public $deleteMode;
40
41
    /**
42
     * @var PnrLocatorData
43
     */
44
    public $pnrLocatorData;
45
46
    /**
47
     * @var PsaList[]
48
     */
49
    public $psaList;
50
51
    /**
52
     * DeleteTST constructor.
53
     *
54
     * @param TicketDeleteTstOptions $params
55
     */
56
    public function __construct(TicketDeleteTstOptions $params)
57
    {
58
        $this->deleteMode = new DeleteMode($params->deleteMode);
59
60
        if ($params->deleteMode === AttributeDetails::MODE_SELECTIVE) {
61
            if (!empty($params->tstTattooNr)) {
62
                $this->psaList[] = new PsaList(
63
                    null,
64
                    ItemReference::REFTYPE_TST,
65
                    $params->tstTattooNr
66
                );
67
            }
68
69
            if (!empty($params->tstNumber)) {
70
                $this->psaList[] = new PsaList(
71
                    $params->tstNumber,
72
                    ItemReference::REFTYPE_TST
73
                );
74
            }
75
76 View Code Duplication
            if (!empty($params->passengerNumber)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
77
                $tmp =  new PsaList(
78
                    null,
79
                    ItemReference::REFTYPE_TST
80
                );
81
82
                $tmp->paxReference = new PaxReference(
83
                    $params->passengerNumber,
84
                    RefDetails::QUAL_PASSENGER
85
                );
86
87
                $this->psaList[] = $tmp;
88
            }
89
90 View Code Duplication
            if (!empty($params->segmentNumber)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
                $tmp =  new PsaList(
92
                    null,
93
                    ItemReference::REFTYPE_TST
94
                );
95
96
                $tmp->paxReference = new PaxReference(
97
                    $params->segmentNumber,
98
                    RefDetails::QUAL_SEGMENT_REFERENCE
99
                );
100
101
                $this->psaList[] = $tmp;
102
            }
103
        }
104
    }
105
}
106