LocationDetails::__construct()   B
last analyzed

Complexity

Conditions 8
Paths 16

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 20
ccs 17
cts 17
cp 1
rs 8.4444
cc 8
nc 16
nop 1
crap 8
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\MPLocation;
26
27
/**
28
 * LocationDetails
29
 *
30
 * @package Amadeus\Client\Struct\Fare\MasterPricer
31
 * @author Dieter Devlieghere <[email protected]>
32
 */
33
class LocationDetails
34
{
35
    /**
36
     * Specifies a reference given to a number of flight segment in the querying system
37
     *
38
     * @var int
39
     */
40
    public $distance;
41
    /**
42
     * Indicates the reference of the number of flight segment
43
     * K  Kilometers
44
     * P  Passenger/traveller reference number
45
     * S  PNR segment reference number
46
     *
47
     * @var string
48
     */
49
    public $distanceUnit;
50
    /**
51
     * Use ATA/IATA defined 3 letter city code
52
     *
53
     * @var string
54
     */
55
    public $locationId;
56
    /**
57
     *
58
     * A  Airport
59
     * C  City
60
     * D  Consider Destination (off point) of the PNR requested segment
61
     * O  Consider Origin (board point) of the PNR requested segment
62
     *
63
     * @var string|null
64
     */
65
    public $airportCityQualifier;
66
    /**
67
     * Latitude in degrees
68
     *
69
     * @var string
70
     */
71
    public $latitude;
72
    /**
73
     * Longitude in degrees
74
     *
75
     * @var string
76
     */
77
    public $longitude;
78
79
    /**
80
     * LocationDetails constructor.
81
     *
82
     * @param MPLocation $location
83
     */
84 330
    public function __construct(MPLocation $location)
85
    {
86 330
        if (!empty($location->airport)) {
87 10
            $this->locationId = $location->airport;
88 10
            $this->airportCityQualifier = "A";
89 330
        } elseif (!empty($location->city)) {
90 320
            $this->locationId = $location->city;
91 320
            $this->airportCityQualifier = "C";
92 128
        } elseif (!empty($location->all)) {
93
            $this->locationId = $location->all;
94 330
        }
95 10
96 10
        if (!empty($location->longitude) && !empty($location->latitude)) {
97 4
            $this->longitude = $location->longitude;
98
            $this->latitude = $location->latitude;
99 330
        }
100 10
101 10
        if (!empty($location->radiusDistance) && !empty($location->radiusUnit)) {
102 4
            $this->distance = $location->radiusDistance;
103 330
            $this->distanceUnit = $location->radiusUnit;
104
        }
105
    }
106
}
107