Completed
Push — master ( 1f73e5...03cb25 )
by Dieter
06:49
created

ProcessEDoc::loadFrequentTravellers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
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\TicketProcessEDocOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\Ticket\ProcessEDoc\CustomerReference;
28
use Amadeus\Client\Struct\Ticket\ProcessEDoc\DocGroup;
29
use Amadeus\Client\Struct\Ticket\ProcessEDoc\FrequentTravellerInfo;
30
use Amadeus\Client\Struct\Ticket\ProcessEDoc\InfoGroup;
31
use Amadeus\Client\Struct\Ticket\ProcessEDoc\MsgActionDetails;
32
use Amadeus\Client\Struct\Ticket\ProcessEDoc\PricingInfo;
33
use Amadeus\Client\Struct\Ticket\ProcessEDoc\TextInfo;
34
35
/**
36
 * TicketProcessEDoc
37
 *
38
 * Basic Request structure for the TicketProcessEDoc messages
39
 *
40
 * @package Amadeus\Client\Struct\Ticket\EDoc
41
 * @author Farah Hourani <[email protected]>
42
 * @author Dieter Devlieghere <[email protected]>
43
 */
44
class ProcessEDoc extends BaseWsMessage
45
{
46
    /**
47
     * @var MsgActionDetails
48
     */
49
    public $msgActionDetails;
50
51
    /**
52
     * @var FrequentTravellerInfo
53
     */
54
    public $frequentTravellerInfo;
55
56
    /**
57
     * @var TextInfo[]
58
     */
59
    public $textInfo = [];
60
61
    /**
62
     * @var CustomerReference
63
     */
64
    public $customerReference;
65
66
    /**
67
     * @var PricingInfo
68
     */
69
    public $pricingInfo;
70
71
    /**
72
     * @var InfoGroup[]
73
     */
74
    public $infoGroup = [];
75
76
    /**
77
     * @var DocGroup[]
78
     */
79
    public $docGroup = [];
80
81
82
    /**
83
     * ProcessEDoc constructor.
84
     *
85
     * @param TicketProcessEDocOptions $options
86
     */
87 3
    public function __construct(TicketProcessEDocOptions $options)
88
    {
89 3
        $this->loadOptions($options->ticketNumber);
90 3
        $this->loadMsgAction($options->action, $options->additionalActions);
91 3
        $this->loadFrequentTravellers($options->frequentTravellers);
92 3
    }
93
94
    /**
95
     * @param string $ticketNumber
96
     */
97 3
    protected function loadOptions($ticketNumber)
98
    {
99 3
        if (!empty($ticketNumber)) {
100 2
            $this->infoGroup[] = new InfoGroup($ticketNumber);
101 2
        }
102 3
    }
103
104
    /**
105
     * @param string $action
106
     * @param string[] $additionalActions
107
     */
108 3
    protected function loadMsgAction($action, $additionalActions)
109
    {
110 3
        if ($this->checkAnyNotEmpty($action, $additionalActions)) {
111 3
            $this->msgActionDetails = new MsgActionDetails($action, $additionalActions);
112 3
        }
113 3
    }
114
115
    /**
116
     * @param $frequentTravellers
117
     */
118 3
    protected function loadFrequentTravellers($frequentTravellers)
119
    {
120 3
        if (!empty($frequentTravellers)) {
121 1
            $this->frequentTravellerInfo = new FrequentTravellerInfo($frequentTravellers);
122 1
        }
123 3
    }
124
}
125