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

IssueMiscellaneousDocuments   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 2
cbo 5
dl 0
loc 68
ccs 35
cts 35
cp 1
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 1
A addSelectionItems() 0 11 2
A loadReferences() 0 16 3
A loadStockReference() 0 6 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\DocIssuance;
24
25
use Amadeus\Client\RequestOptions\DocIssuanceIssueMiscDocOptions;
26
27
/**
28
 * DocIssuance_IssueMiscellaneousDocuments request structure
29
 *
30
 * @package Amadeus\Client\Struct\DocIssuance
31
 * @author Dieter Devlieghere <[email protected]>
32
 */
33
class IssueMiscellaneousDocuments extends DocIssuanceBaseMsg
34
{
35
    /**
36
     * IssueMiscellaneousDocuments constructor.
37
     *
38
     * @param DocIssuanceIssueMiscDocOptions $options
39
     */
40 9
    public function __construct(DocIssuanceIssueMiscDocOptions $options)
41
    {
42 9
        $this->addSelectionItems($options->tsmNumbers, ReferenceDetails::TYPE_TSM);
43 9
        $this->addSelectionItems($options->tsmTattoos, ReferenceDetails::TYPE_TSM_TATTOO);
44 9
        $this->addSelectionItems($options->lineNumbers, ReferenceDetails::TYPE_LINE_NUMBER);
45
46 9
        $this->loadOptions($options->options, $options->compoundOptions);
47
48 9
        $this->loadReferences($options);
49
50 9
        $this->loadPassType($options->passengerType);
51
52 9
        $this->loadStockReference($options->stockReference);
53 9
    }
54
55
    /**
56
     * @param string[]|int[] $list
57
     * @param string $type
58
     */
59 9
    protected function addSelectionItems($list, $type)
60
    {
61 9
        foreach ($list as $item) {
62 2
            $this->addSelectionItem(
63 2
                new ReferenceDetails(
64 2
                    $item,
65
                    $type
66 2
                )
67 2
            );
68 9
        }
69 9
    }
70
71
    /**
72
     * @param DocIssuanceIssueMiscDocOptions $options
73
     */
74 9
    protected function loadReferences($options)
75
    {
76 9
        foreach ($options->passengerNumbers as $paxNum) {
77 1
            $this->paxSelection[] = new PaxSelection(
78 1
                $paxNum,
79
                PassengerReference::TYPE_PAX_SELECTION
80 2
            );
81 9
        }
82
83 9
        foreach ($options->passengerTattoos as $paxTat) {
84 1
            $this->paxSelection[] = new PaxSelection(
85 1
                $paxTat,
86
                PassengerReference::TYPE_PAX_TATTOO
87 1
            );
88 9
        }
89 9
    }
90
91
    /**
92
     * @param string|null $stockRef
93
     */
94 9
    protected function loadStockReference($stockRef)
95
    {
96 9
        if (!is_null($stockRef)) {
97 1
            $this->stock = new Stock($stockRef);
98 1
        }
99 9
    }
100
}
101