Passed
Push — master ( 5b9625...a3c6c3 )
by Artem
03:31
created

RetrievalFacts::__construct()   B

Complexity

Conditions 6
Paths 24

Size

Total Lines 38
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 25
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 38
ccs 25
cts 25
cp 1
rs 8.8977
cc 6
nc 24
nop 1
crap 6
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\Pnr\Retrieve;
24
25
use Amadeus\Client\RequestOptions\Pnr\Retrieve\FrequentTraveller;
26
use Amadeus\Client\RequestOptions\PnrRetrieveOptions;
27
use Amadeus\Client\Struct\Pnr\Retrieve as RetrieveMsg;
28
use Amadeus\Client\Struct\WsMessageUtility;
29
30
/**
31
 * Structure class for the RetrievalFacts message part for PNR_Retrieve messages
32
 *
33
 * @package Amadeus\Client\Struct\Pnr\Retrieve
34
 * @author Dieter Devlieghere <[email protected]>
35
 */
36
class RetrievalFacts extends WsMessageUtility
37
{
38
    /**
39
     * @var Retrieve
40
     */
41
    public $retrieve;
42
43
    /**
44
     * @var ReservationOrProfileIdentifier
45
     */
46
    public $reservationOrProfileIdentifier;
47
48
    /**
49
     * @var PersonalFacts
50
     */
51
    public $personalFacts;
52
53
    /**
54
     * @var FrequentFlyer
55
     */
56
    public $frequentFlyer;
57
58
    /**
59
     * @var Accounting
60
     */
61
    public $accounting;
62
63
    /**
64
     * Construct retrievalFacts element
65
     *
66
     * @param PnrRetrieveOptions $options
67
     */
68 115
    public function __construct($options)
69
    {
70 115
        $this->retrieve = new Retrieve(
71 115
            $options->retrievalType,
72 115
            $options->officeId,
73 46
            $options->options
74
        );
75 115
76 5
        if ($this->checkAnyNotEmpty($options->accountNumber)) {
77 2
            $this->accounting = new Accounting($options->accountNumber);
78
        }
79 115
80 75
        if ($this->checkAnyNotEmpty($options->recordLocator, $options->customerProfile)) {
81
            $controlNumber = $options->retrievalType === RetrieveMsg::RETR_TYPE_BY_CUSTOMER_PROFILE
82 75
                ? $options->customerProfile
83 30
                : $options->recordLocator;
84
85 115
            $this->reservationOrProfileIdentifier = new ReservationOrProfileIdentifier($controlNumber);
86 20
        }
87 20
88 20
        if ($this->checkAnyNotEmpty(
89 20
            $options->lastName,
90 20
            $options->departureDate,
91 20
            $options->ticket,
92 8
            $options->company,
93 8
            $options->flightNumber,
94
        )) {
95 115
            $this->personalFacts = new PersonalFacts(
96 5
                $options->lastName,
97 2
                $options->departureDate,
98 115
                $options->ticket,
99
                $options->company,
100
                $options->flightNumber
101
            );
102
        }
103
104
        if ($options->frequentTraveller instanceof FrequentTraveller) {
0 ignored issues
show
introduced by
$options->frequentTraveller is always a sub-type of Amadeus\Client\RequestOp...rieve\FrequentTraveller.
Loading history...
105
            $this->frequentFlyer = new FrequentFlyer($options->frequentTraveller);
106
        }
107
    }
108
}
109