Completed
Push — develop ( 79a83d...d8326f )
by Dieter
05:21
created

GeneralFlightInfo::loadArrivalLocation()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 3
nc 2
nop 1
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\Air;
24
use Amadeus\Client\RequestOptions\AirFlightInfoOptions;
25
26
/**
27
 * GeneralFlightInfo
28
 *
29
 * @package Amadeus\Client\Struct\Air
30
 * @author Dieter Devlieghere <[email protected]>
31
 */
32
class GeneralFlightInfo
33
{
34
    /**
35
     * @var FlightDate
36
     */
37
    public $flightDate;
38
    /**
39
     * @var PointDetails
40
     */
41
    public $boardPointDetails;
42
    /**
43
     * @var PointDetails
44
     */
45
    public $offPointDetails;
46
    /**
47
     * @var CompanyDetails
48
     */
49
    public $companyDetails;
50
    /**
51
     * @var FlightIdentification
52
     */
53
    public $flightIdentification;
54
    /**
55
     * @var FlightTypeDetails
56
     */
57
    public $flightTypeDetails;
58
    /**
59
     * @var MarriageDetails[]
60
     */
61
    public $marriageDetails = [];
62
63
    /**
64
     * @param AirFlightInfoOptions $params
65
     */
66
    public function __construct(AirFlightInfoOptions $params)
67
    {
68
        $this->loadAirlineCode($params);
69
70
        $this->loadFlightNumber($params);
71
72
        $this->loadDepartureDate($params);
73
        $this->loadDepartureLocation($params);
74
        $this->loadArrivalLocation($params);
75
    }
76
77
    /**
78
     * @param AirFlightInfoOptions $params
79
     * @return void
80
     */
81
    protected function loadAirlineCode(AirFlightInfoOptions $params)
82
    {
83
        if ($params->airlineCode !== null) {
84
            $this->companyDetails = new CompanyDetails($params->airlineCode);
85
        }
86
    }
87
88
    /**
89
     * @param AirFlightInfoOptions $params
90
     * @return void
91
     */
92
    protected function loadFlightNumber(AirFlightInfoOptions $params)
93
    {
94
        if ($params->flightNumber !== null) {
95
            $this->flightIdentification = new FlightIdentification(
96
                $params->flightNumber,
97
                null,
98
                $params->flightNumberSuffix
99
            );
100
        }
101
    }
102
103
    /**
104
     * @param AirFlightInfoOptions $params
105
     * @return void
106
     */
107
    protected function loadDepartureDate(AirFlightInfoOptions $params)
108
    {
109
        if ($params->departureDate instanceof \DateTime) {
110
            $this->flightDate = new FlightDate($params->departureDate->format('dmy'));
111
        }
112
    }
113
114
    /**
115
     * @param AirFlightInfoOptions $params
116
     * @return void
117
     */
118
    protected function loadDepartureLocation(AirFlightInfoOptions $params)
119
    {
120
        if ($params->departureLocation !== null && strlen($params->departureLocation) === 3) {
121
            $this->boardPointDetails = new PointDetails($params->departureLocation);
122
        }
123
    }
124
125
    /**
126
     * @param AirFlightInfoOptions $params
127
     * @return void
128
     */
129
    protected function loadArrivalLocation(AirFlightInfoOptions $params)
130
    {
131
        if ($params->arrivalLocation !== null && strlen($params->arrivalLocation) === 3) {
132
            $this->offPointDetails = new PointDetails($params->arrivalLocation);
133
        }
134
    }
135
}
136