|
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; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* WsMessageUtility - provides utility functions when constructing web service messages |
|
27
|
|
|
* |
|
28
|
|
|
* @package Amadeus\Client\Struct |
|
29
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class WsMessageUtility |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* Check if any parameter to the current function is not empty |
|
35
|
|
|
* |
|
36
|
|
|
* @param mixed |
|
37
|
|
|
* @return boolean true if at least 1 parameter is not empty |
|
38
|
|
|
*/ |
|
39
|
84 |
|
protected function checkAnyNotEmpty() |
|
40
|
|
|
{ |
|
41
|
84 |
|
$foundNotEmpty = false; |
|
42
|
|
|
|
|
43
|
84 |
|
$args = func_get_args(); |
|
44
|
|
|
|
|
45
|
84 |
|
foreach ($args as $arg) { |
|
46
|
84 |
|
if (!empty($arg)) { |
|
47
|
58 |
|
$foundNotEmpty = true; |
|
48
|
58 |
|
break; |
|
49
|
|
|
} |
|
50
|
84 |
|
} |
|
51
|
|
|
|
|
52
|
84 |
|
return $foundNotEmpty; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Check if all parameters to the current function are not empty |
|
57
|
|
|
* |
|
58
|
|
|
* @param mixed |
|
59
|
|
|
* @return boolean true if all parameters are not empty |
|
60
|
|
|
*/ |
|
61
|
34 |
|
protected function checkAllNotEmpty() |
|
62
|
|
|
{ |
|
63
|
34 |
|
$foundEmpty = false; |
|
64
|
|
|
|
|
65
|
34 |
|
$args = func_get_args(); |
|
66
|
|
|
|
|
67
|
34 |
|
foreach ($args as $arg) { |
|
68
|
34 |
|
if (empty($arg)) { |
|
69
|
22 |
|
$foundEmpty = true; |
|
70
|
22 |
|
break; |
|
71
|
|
|
} |
|
72
|
34 |
|
} |
|
73
|
|
|
|
|
74
|
34 |
|
return !$foundEmpty; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Check if all parameters to the current function are integers |
|
79
|
|
|
* |
|
80
|
|
|
* @param mixed |
|
81
|
|
|
* @return boolean true if all parameters are integers |
|
82
|
|
|
*/ |
|
83
|
7 |
|
protected function checkAllIntegers() |
|
84
|
|
|
{ |
|
85
|
7 |
|
$foundNonInt = false; |
|
86
|
|
|
|
|
87
|
7 |
|
$args = func_get_args(); |
|
88
|
|
|
|
|
89
|
7 |
|
foreach ($args as $arg) { |
|
90
|
7 |
|
if (!is_int($arg)) { |
|
91
|
6 |
|
$foundNonInt = true; |
|
92
|
6 |
|
break; |
|
93
|
|
|
} |
|
94
|
7 |
|
} |
|
95
|
|
|
|
|
96
|
7 |
|
return !$foundNonInt; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Check if any parameter to the current function is true |
|
101
|
|
|
* |
|
102
|
|
|
* @param mixed |
|
103
|
|
|
* @return boolean true if at least 1 parameter is true |
|
104
|
|
|
*/ |
|
105
|
5 |
|
protected function checkAnyTrue() |
|
106
|
|
|
{ |
|
107
|
5 |
|
$foundTrue = false; |
|
108
|
|
|
|
|
109
|
5 |
|
$args = func_get_args(); |
|
110
|
|
|
|
|
111
|
5 |
|
foreach ($args as $arg) { |
|
112
|
5 |
|
if ($arg === true) { |
|
113
|
2 |
|
$foundTrue = true; |
|
114
|
2 |
|
break; |
|
115
|
|
|
} |
|
116
|
5 |
|
} |
|
117
|
|
|
|
|
118
|
5 |
|
return $foundTrue; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|