DeleteTST::__construct()   B
last analyzed

Complexity

Conditions 6
Paths 17

Size

Total Lines 49

Duplication

Lines 26
Ratio 53.06 %

Importance

Changes 0
Metric Value
dl 26
loc 49
rs 8.4905
c 0
b 0
f 0
cc 6
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
use Amadeus\Client\Struct\Ticket\DeleteTST\DeleteMode;
28
29
/**
30
 * Ticket_DeleteTST
31
 *
32
 * @package Amadeus\Client\Struct\Ticket
33
 * @author Dieter Devlieghere <[email protected]>
34
 */
35
class DeleteTST extends BaseWsMessage
36
{
37
    /**
38
     * @var DeleteMode
39
     */
40
    public $deleteMode;
41
42
    /**
43
     * @var PnrLocatorData
44
     */
45
    public $pnrLocatorData;
46
47
    /**
48
     * @var PsaList[]
49
     */
50
    public $psaList;
51
52
    /**
53
     * DeleteTST constructor.
54
     *
55
     * @param TicketDeleteTstOptions $params
56
     */
57
    public function __construct(TicketDeleteTstOptions $params)
58
    {
59
        $this->deleteMode = new DeleteMode($params->deleteMode);
60
61
        if ($params->deleteMode === AttributeDetails::MODE_SELECTIVE) {
62
            if (!empty($params->tstTattooNr)) {
63
                $this->psaList[] = new PsaList(
64
                    null,
65
                    ItemReference::REFTYPE_TST,
66
                    $params->tstTattooNr
67
                );
68
            }
69
70
            if (!empty($params->tstNumber)) {
71
                $this->psaList[] = new PsaList(
72
                    $params->tstNumber,
73
                    ItemReference::REFTYPE_TST
74
                );
75
            }
76
77 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...
78
                $tmp = new PsaList(
79
                    null,
80
                    ItemReference::REFTYPE_TST
81
                );
82
83
                $tmp->paxReference = new PaxReference(
84
                    $params->passengerNumber,
85
                    RefDetails::QUAL_PASSENGER
86
                );
87
88
                $this->psaList[] = $tmp;
89
            }
90
91 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...
92
                $tmp = new PsaList(
93
                    null,
94
                    ItemReference::REFTYPE_TST
95
                );
96
97
                $tmp->paxReference = new PaxReference(
98
                    $params->segmentNumber,
99
                    RefDetails::QUAL_SEGMENT_REFERENCE
100
                );
101
102
                $this->psaList[] = $tmp;
103
            }
104
        }
105
    }
106
}
107