Passed
Pull Request — master (#481)
by Artem
04:27
created

DeleteTSMP::__construct()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 9
cts 9
cp 1
rs 10
cc 4
nc 8
nop 1
crap 4
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\TicketDeleteTsmpOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\Ticket\DeleteTSMP\CriteriaTattoo;
28
use Amadeus\Client\Struct\Ticket\DeleteTSMP\ReferenceDetails;
29
30
/**
31
 * DeleteTSMP
32
 *
33
 * @package Amadeus\Client\Struct\Ticket
34
 * @author Dieter Devlieghere <[email protected]>
35
 */
36
class DeleteTSMP extends BaseWsMessage
37
{
38
    /**
39
     * @var CriteriaTattoo[]
40
     */
41
    public $criteriaTattoo = [];
42
43
    /**
44
     * DeleteTSMP constructor.
45
     *
46
     * @param TicketDeleteTsmpOptions $params
47
     */
48 25
    public function __construct(TicketDeleteTsmpOptions $params)
49
    {
50 25
        foreach ($params->infantTattoos as $infantTattoo) {
51 10
            $this->addCriteriaTattoo($infantTattoo, ReferenceDetails::TYPE_INFANT_PARENT_TATTOO);
52 10
        }
53
54 25
        foreach ($params->paxTattoos as $paxTattoo) {
55 15
            $this->addCriteriaTattoo($paxTattoo, ReferenceDetails::TYPE_PASSENGER_TATTOO);
56 10
        }
57
58 25
        foreach ($params->tsmTattoos as $tsmTattoo) {
59 10
            $this->addCriteriaTattoo($tsmTattoo, ReferenceDetails::TYPE_TSM_TATTOO);
60 10
        }
61 25
    }
62
63
    /**
64
     * Add a tattoo ref to the message
65
     *
66
     * @param string|int $tattoo
67
     * @param string $type
68
     */
69 25
    protected function addCriteriaTattoo($tattoo, $type)
70
    {
71 25
        $this->criteriaTattoo[] = new CriteriaTattoo($type, $tattoo);
72 25
    }
73
}
74