Completed
Push — master ( a82346...60b026 )
by Dieter
09:40
created

CreateFormOfPayment::loadFopGroup()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
c 1
b 1
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3
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
        $this->loadFopGroup($options);
77 64
    }
78
79
    /**
80
     * Load fopGroup
81
     *
82
     * @param FopCreateFopOptions $options
83
     */
84 64
    protected function loadFopGroup(FopCreateFopOptions $options)
85
    {
86 64
        foreach ($options->fopGroup as $group) {
87 64
            if ($this instanceof CreateFormOfPayment14) {
88 8
                $this->fopGroup[] = new FopGroup14($group);
89 4
            } else {
90 60
                $this->fopGroup[] = new FopGroup($group);
91
            }
92 32
        }
93 64
    }
94
}
95