Completed
Push — master ( 738038...14ebb8 )
by Dieter
11:17
created

IssueTicket::addSelectionItem()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 4
nc 2
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\DocIssuance;
24
25
use Amadeus\Client\RequestOptions\DocIssuanceIssueTicketOptions;
26
27
/**
28
 * DocIssuance_IssueTicket request structure
29
 *
30
 * @package Amadeus\Client\Struct\DocIssuance
31
 * @author Dieter Devlieghere <[email protected]>
32
 */
33
class IssueTicket extends DocIssuanceBaseMsg
34
{
35
    /**
36
     * @var AgentInfo
37
     */
38
    public $agentInfo;
39
40
    /**
41
     * @var OverrideDate
42
     */
43
    public $overrideDate;
44
45
46
    /**
47
     * IssueTicket constructor.
48
     *
49
     * @param DocIssuanceIssueTicketOptions $options
50
     */
51 9
    public function __construct(DocIssuanceIssueTicketOptions $options)
52
    {
53 9
        foreach ($options->tsts as $tst) {
54 1
            $this->addSelectionItem(
55 1
                new ReferenceDetails(
56 1
                    $tst,
57
                    ReferenceDetails::TYPE_TST
58 1
                )
59 2
            );
60 9
        }
61
62 9
        $this->loadOverrideDate($options);
63
64 9
        $this->loadReferences($options);
65
66 9
        $this->loadOptions($options->options, $options->compoundOptions);
67
68 9
        if (!empty($options->agentCode)) {
69 1
            $this->agentInfo = new AgentInfo($options->agentCode);
70 1
        }
71
72 9
        $this->loadPassType($options->passengerType);
73 9
    }
74
75
    /**
76
     * @param DocIssuanceIssueTicketOptions $options
77
     */
78 9
    protected function loadOverrideDate(DocIssuanceIssueTicketOptions $options)
79
    {
80 9
        if ($options->alternateDateValidation instanceof \DateTime) {
81 1
            $this->overrideDate = new OverrideDate(
82 1
                OverrideDate::OPT_ALTERNATE_DATE_VALIDATION,
83 1
                $options->alternateDateValidation
84 1
            );
85 9
        } elseif ($options->overridePastDateTst === true) {
86 1
            $this->overrideDate = new OverrideDate(OverrideDate::OPT_OVERRIDE_PAST_DATE_TST);
87 1
        }
88 9
    }
89
90
    /**
91
     * @param DocIssuanceIssueTicketOptions $options
92
     */
93 9
    protected function loadReferences(DocIssuanceIssueTicketOptions $options)
94
    {
95 9
        foreach ($options->passengerTattoos as $passengerTattoo) {
96 1
            $this->paxSelection[] = new PaxSelection($passengerTattoo);
97 9
        }
98
99 9
        foreach ($options->segmentTattoos as $segmentTattoo) {
100 1
            $this->addSelectionItem(
101 1
                new ReferenceDetails(
102 1
                    $segmentTattoo,
103
                    ReferenceDetails::TYPE_SEGMENT_TATTOO
104 1
                )
105 1
            );
106 9
        }
107 9
    }
108
}
109