|
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\MPDate; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\MPTripDetails; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* TimeDetails |
|
30
|
|
|
* |
|
31
|
|
|
* @package Amadeus\Client\Struct\Fare\MasterPricer |
|
32
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
33
|
|
|
*/ |
|
34
|
|
|
class TimeDetails |
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var FirstDateTimeDetail |
|
38
|
|
|
*/ |
|
39
|
|
|
public $firstDateTimeDetail; |
|
40
|
|
|
/** |
|
41
|
|
|
* @var RangeOfDate |
|
42
|
|
|
*/ |
|
43
|
|
|
public $rangeOfDate; |
|
44
|
|
|
/** |
|
45
|
|
|
* @var TripDetails |
|
46
|
|
|
*/ |
|
47
|
|
|
public $tripDetails; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* TimeDetails constructor. |
|
51
|
|
|
* |
|
52
|
|
|
* @param MPDate $theDate |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct(MPDate $theDate) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->firstDateTimeDetail = new FirstDateTimeDetail( |
|
57
|
|
|
$this->makeDateString($theDate->dateTime, $theDate->date) |
|
|
|
|
|
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
$timeString = $this->makeTimeString($theDate->dateTime, $theDate->time); |
|
|
|
|
|
|
61
|
|
|
if ($timeString !== '0000') { |
|
62
|
|
|
$this->firstDateTimeDetail->time = $timeString; |
|
63
|
|
|
|
|
64
|
|
|
if ($theDate->isDeparture) { |
|
65
|
|
|
$this->firstDateTimeDetail->timeQualifier = FirstDateTimeDetail::TIMEQUAL_DEPART_FROM; |
|
66
|
|
|
} else { |
|
67
|
|
|
$this->firstDateTimeDetail->timeQualifier = FirstDateTimeDetail::TIMEQUAL_ARRIVAL_BY; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
if (is_int($theDate->timeWindow)) { |
|
72
|
|
|
$this->firstDateTimeDetail->timeWindow = $theDate->timeWindow; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
if (!is_null($theDate->range) && !is_null($theDate->rangeMode)) { |
|
76
|
|
|
$this->rangeOfDate = new RangeOfDate( |
|
77
|
|
|
$theDate->rangeMode, |
|
78
|
|
|
$theDate->range |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
if (!is_null($theDate->tripDetails) && $theDate->tripDetails instanceof MPTripDetails) { |
|
83
|
|
|
$this->tripDetails = new TripDetails($theDate->tripDetails); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param \DateTime|null $dateTime |
|
89
|
|
|
* @param \DateTime|null $date |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
protected function makeDateString($dateTime, $date) |
|
93
|
|
|
{ |
|
94
|
|
|
$dateStr = '000000'; |
|
95
|
|
|
|
|
96
|
|
|
if ($dateTime instanceof \DateTime) { |
|
97
|
|
|
$dateStr = $dateTime->format('dmy'); |
|
98
|
|
|
} elseif ($date instanceof \DateTime) { |
|
99
|
|
|
$dateStr = $date->format('dmy'); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
return $dateStr; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @param \DateTime|null $dateTime |
|
107
|
|
|
* @param \DateTime|null $time |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
|
|
protected function makeTimeString($dateTime, $time) |
|
111
|
|
|
{ |
|
112
|
|
|
$timeStr = '0000'; |
|
113
|
|
|
|
|
114
|
|
|
if ($dateTime instanceof \DateTime) { |
|
115
|
|
|
$timeStr = $dateTime->format('Hi'); |
|
116
|
|
|
} elseif ($time instanceof \DateTime) { |
|
117
|
|
|
$timeStr = $time->format('Hi'); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
return $timeStr; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
|
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.