Completed
Push — master ( 83dd31...9c77e3 )
by Dieter
08:50
created

CreateFormOfPayment::__construct()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
ccs 17
cts 17
cp 1
rs 8.7624
cc 5
eloc 12
nc 12
nop 1
crap 5
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\Fop;
24
25
use Amadeus\Client\RequestOptions\FopCreateFopOptions;
26
use Amadeus\Client\Struct\BaseWsMessage;
27
use Amadeus\Client\Struct\Fop\CreateFormOfPayment\BestEffort;
28
use Amadeus\Client\Struct\Fop\CreateFormOfPayment\FopGroup14;
29
30
/**
31
 * FOP_CreateFormOfPayment message structure version 15 and up
32
 *
33
 * @package Amadeus\Client\Struct\Fop
34
 * @author Dieter Devlieghere <[email protected]>
35
 */
36
class CreateFormOfPayment extends BaseWsMessage
37
{
38
    /**
39
     * @var TransactionContext
40
     */
41
    public $transactionContext;
42
43
    /**
44
     * @var BestEffort[]
45
     */
46
    public $bestEffort = [];
47
48
    /**
49
     * @var ReservationControlInformation
50
     */
51
    public $reservationControlInformation;
52
53
    /**
54
     * @var FopGroup[]
55
     */
56
    public $fopGroup = [];
57
58
    /**
59
     * FOP_CreateFormOfPayment constructor.
60
     *
61
     * @param FopCreateFopOptions $options
62
     */
63 64
    public function __construct(FopCreateFopOptions $options)
64
    {
65 64
        if ($this->checkAnyNotEmpty($options->transactionCode, $options->obFeeCalculation)) {
66 56
            $this->transactionContext = new TransactionContext(
67 56
                $options->transactionCode,
68 56
                $options->obFeeCalculation
69 28
            );
70 28
        }
71
72 64
        if ($this->checkAllNotEmpty($options->bestEffortAction, $options->bestEffortIndicator)) {
73 4
            $this->bestEffort[] = new BestEffort($options->bestEffortIndicator, $options->bestEffortAction);
74 2
        }
75
76 64
        foreach ($options->fopGroup as $group) {
77 64
            if ($this instanceof CreateFormOfPayment14) {
78 8
                $this->fopGroup[] = new FopGroup14($group);
79 4
            } else {
80 60
                $this->fopGroup[] = new FopGroup($group);
81
            }
82 32
        }
83 64
    }
84
}
85