Completed
Push — master ( c270ad...b8baec )
by Dieter
14:46 queued 06:10
created

NumberOfUnit::__construct()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 5

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 30
ccs 23
cts 23
cp 1
rs 8.439
cc 5
eloc 19
nc 8
nop 3
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\Fare\MasterPricer;
24
25
use Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights;
26
27
/**
28
 * NumberOfUnit
29
 *
30
 * @package Amadeus\Client\Struct\Fare\MasterPricer
31
 * @author Dieter Devlieghere <[email protected]>
32
 */
33
class NumberOfUnit
34
{
35
    /**
36
     * @var UnitNumberDetail[]
37
     */
38
    public $unitNumberDetail = [];
39
40
    /**
41
     * @param int|null $requestedPax
42
     * @param int|null $requestedResults
43
     * @param Amadeus\Client\RequestOptions\Fare\MasterPricer\MultiTicketWeights|null $multiTicketWeights
44
     */
45 29
    public function __construct($requestedPax, $requestedResults, $multiTicketWeights)
46
    {
47 29
        if (is_int($requestedPax)) {
48 29
            $this->unitNumberDetail[] = new UnitNumberDetail(
49 29
                $requestedPax,
50
                UnitNumberDetail::TYPE_PASS
51 29
            );
52 29
        }
53 29
        if (is_int($requestedResults)) {
54 24
            $this->unitNumberDetail[] = new UnitNumberDetail(
55 24
                $requestedResults,
56
                UnitNumberDetail::TYPE_RESULTS
57 24
            );
58 24
        }
59
60 29
        if ($multiTicketWeights && $multiTicketWeights instanceof MultiTicketWeights) {
61 1
            $this->unitNumberDetail[] = new UnitNumberDetail(
62 1
                $multiTicketWeights->oneWayOutbound,
63
                UnitNumberDetail::TYPE_OUTBOUND_RECOMMENDATION
64 1
            );
65 1
            $this->unitNumberDetail[] = new UnitNumberDetail(
66 1
                $multiTicketWeights->oneWayInbound,
67
                UnitNumberDetail::TYPE_INBBOUND_RECOMMENDATION
68 1
            );
69 1
            $this->unitNumberDetail[] = new UnitNumberDetail(
70 1
                $multiTicketWeights->returnTrip,
71
                UnitNumberDetail::TYPE_COMPLETE_RECOMMENDATION
72 1
            );
73 1
        }
74 29
    }
75
}
76