Completed
Push — master ( 1ecee2...1e59ec )
by Dieter
07:27
created

DisplayTST   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
C loadSelective() 0 27 8
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\TicketDisplayTstOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
28
/**
29
 * DisplayTST
30
 *
31
 * @package Amadeus\Client\Struct\Ticket
32
 * @author Dieter Devlieghere <[email protected]>
33
 */
34
class DisplayTST extends BaseWsMessage
35
{
36
    /**
37
     * @var DisplayMode
38
     */
39
    public $displayMode;
40
41
    /**
42
     * @var PnrLocatorData
43
     */
44
    public $pnrLocatorData;
45
46
    /**
47
     * @var ScrollingInformation
48
     */
49
    public $scrollingInformation;
50
51
    /**
52
     * @var TstReference[]
53
     */
54
    public $tstReference = [];
55
56
    /**
57
     * @var PsaInformation
58
     */
59
    public $psaInformation;
60
61
    /**
62
     * DisplayTST constructor.
63
     *
64
     * @param TicketDisplayTstOptions $params
65
     */
66
    public function __construct(TicketDisplayTstOptions $params)
67
    {
68
        $this->displayMode = new DisplayMode($params->displayMode);
69
70
        if ($params->displayMode === AttributeDetails::MODE_SELECTIVE) {
71
            $this->loadSelective($params);
72
        }
73
    }
74
75
    /**
76
     * @param TicketDisplayTstOptions $params
77
     */
78
    protected function loadSelective($params)
79
    {
80
        if (!empty($params->tstNumbers)) {
81
            foreach ($params->tstNumbers as $tstNumber) {
82
                $this->tstReference[] = new TstReference($tstNumber);
83
            }
84
        }
85
86
        if ($this->checkAnyNotEmpty($params->passengers, $params->segments)) {
87
            $this->psaInformation = new PsaInformation();
88
89
            foreach ($params->passengers as $passenger) {
90
                $this->psaInformation->refDetails[] = new RefDetails($passenger, RefDetails::QUAL_PASSENGER);
91
            }
92
93
            foreach ($params->segments as $segment) {
94
                $this->psaInformation->refDetails[] = new RefDetails($segment, RefDetails::QUAL_SEGMENT_REFERENCE);
95
            }
96
        }
97
98
        if (!empty($params->scrollingCount) && !empty($params->scrollingStart)) {
99
            $this->scrollingInformation = new ScrollingInformation(
100
                $params->scrollingCount,
101
                $params->scrollingStart
102
            );
103
        }
104
    }
105
}
106