1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace PhpOffice\PhpSpreadsheet\Calculation;
|
|
|
4 |
|
|
|
5 |
use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
* @deprecated 1.17.0
|
|
|
9 |
*/
|
|
|
10 |
class Logical
|
|
|
11 |
{
|
|
|
12 |
/**
|
|
|
13 |
* TRUE.
|
|
|
14 |
*
|
|
|
15 |
* Returns the boolean TRUE.
|
|
|
16 |
*
|
|
|
17 |
* Excel Function:
|
|
|
18 |
* =TRUE()
|
|
|
19 |
*
|
|
|
20 |
* @deprecated 1.17.0
|
|
|
21 |
* Use the TRUE() method in the Logical\Boolean class instead
|
|
|
22 |
* @see Logical\Boolean::TRUE()
|
|
|
23 |
*
|
|
|
24 |
* @return bool True
|
|
|
25 |
*/
|
|
|
26 |
public static function true(): bool
|
|
|
27 |
{
|
|
|
28 |
return Boolean::true();
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* FALSE.
|
|
|
33 |
*
|
|
|
34 |
* Returns the boolean FALSE.
|
|
|
35 |
*
|
|
|
36 |
* Excel Function:
|
|
|
37 |
* =FALSE()
|
|
|
38 |
*
|
|
|
39 |
* @deprecated 1.17.0
|
|
|
40 |
* Use the FALSE() method in the Logical\Boolean class instead
|
|
|
41 |
* @see Logical\Boolean::FALSE()
|
|
|
42 |
*
|
|
|
43 |
* @return bool False
|
|
|
44 |
*/
|
|
|
45 |
public static function false(): bool
|
|
|
46 |
{
|
|
|
47 |
return Boolean::false();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
/**
|
|
|
51 |
* LOGICAL_AND.
|
|
|
52 |
*
|
|
|
53 |
* Returns boolean TRUE if all its arguments are TRUE; returns FALSE if one or more argument is FALSE.
|
|
|
54 |
*
|
|
|
55 |
* Excel Function:
|
|
|
56 |
* =AND(logical1[,logical2[, ...]])
|
|
|
57 |
*
|
|
|
58 |
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
|
|
59 |
* or references that contain logical values.
|
|
|
60 |
*
|
|
|
61 |
* Boolean arguments are treated as True or False as appropriate
|
|
|
62 |
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
|
|
63 |
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
|
|
|
64 |
* holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
|
|
65 |
*
|
|
|
66 |
* @deprecated 1.17.0
|
|
|
67 |
* Use the logicalAnd() method in the Logical\Operations class instead
|
|
|
68 |
* @see Logical\Operations::logicalAnd()
|
|
|
69 |
*
|
|
|
70 |
* @param mixed ...$args Data values
|
|
|
71 |
*
|
|
|
72 |
* @return bool|string the logical AND of the arguments
|
|
|
73 |
*/
|
|
|
74 |
public static function logicalAnd(...$args)
|
|
|
75 |
{
|
|
|
76 |
return Logical\Operations::logicalAnd(...$args);
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* LOGICAL_OR.
|
|
|
81 |
*
|
|
|
82 |
* Returns boolean TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
|
|
|
83 |
*
|
|
|
84 |
* Excel Function:
|
|
|
85 |
* =OR(logical1[,logical2[, ...]])
|
|
|
86 |
*
|
|
|
87 |
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
|
|
88 |
* or references that contain logical values.
|
|
|
89 |
*
|
|
|
90 |
* Boolean arguments are treated as True or False as appropriate
|
|
|
91 |
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
|
|
92 |
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
|
|
|
93 |
* holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
|
|
94 |
*
|
|
|
95 |
* @deprecated 1.17.0
|
|
|
96 |
* Use the logicalOr() method in the Logical\Operations class instead
|
|
|
97 |
* @see Logical\Operations::logicalOr()
|
|
|
98 |
*
|
|
|
99 |
* @param mixed $args Data values
|
|
|
100 |
*
|
|
|
101 |
* @return bool|string the logical OR of the arguments
|
|
|
102 |
*/
|
|
|
103 |
public static function logicalOr(...$args)
|
|
|
104 |
{
|
|
|
105 |
return Logical\Operations::logicalOr(...$args);
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
/**
|
|
|
109 |
* LOGICAL_XOR.
|
|
|
110 |
*
|
|
|
111 |
* Returns the Exclusive Or logical operation for one or more supplied conditions.
|
|
|
112 |
* i.e. the Xor function returns TRUE if an odd number of the supplied conditions evaluate to TRUE,
|
|
|
113 |
* and FALSE otherwise.
|
|
|
114 |
*
|
|
|
115 |
* Excel Function:
|
|
|
116 |
* =XOR(logical1[,logical2[, ...]])
|
|
|
117 |
*
|
|
|
118 |
* The arguments must evaluate to logical values such as TRUE or FALSE, or the arguments must be arrays
|
|
|
119 |
* or references that contain logical values.
|
|
|
120 |
*
|
|
|
121 |
* Boolean arguments are treated as True or False as appropriate
|
|
|
122 |
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
|
|
123 |
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
|
|
|
124 |
* holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
|
|
125 |
*
|
|
|
126 |
* @deprecated 1.17.0
|
|
|
127 |
* Use the logicalXor() method in the Logical\Operations class instead
|
|
|
128 |
* @see Logical\Operations::logicalXor()
|
|
|
129 |
*
|
|
|
130 |
* @param mixed $args Data values
|
|
|
131 |
*
|
|
|
132 |
* @return bool|string the logical XOR of the arguments
|
|
|
133 |
*/
|
|
|
134 |
public static function logicalXor(...$args)
|
|
|
135 |
{
|
|
|
136 |
return Logical\Operations::logicalXor(...$args);
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
/**
|
|
|
140 |
* NOT.
|
|
|
141 |
*
|
|
|
142 |
* Returns the boolean inverse of the argument.
|
|
|
143 |
*
|
|
|
144 |
* Excel Function:
|
|
|
145 |
* =NOT(logical)
|
|
|
146 |
*
|
|
|
147 |
* The argument must evaluate to a logical value such as TRUE or FALSE
|
|
|
148 |
*
|
|
|
149 |
* Boolean arguments are treated as True or False as appropriate
|
|
|
150 |
* Integer or floating point arguments are treated as True, except for 0 or 0.0 which are False
|
|
|
151 |
* If any argument value is a string, or a Null, the function returns a #VALUE! error, unless the string
|
|
|
152 |
* holds the value TRUE or FALSE, in which case it is evaluated as the corresponding boolean value
|
|
|
153 |
*
|
|
|
154 |
* @deprecated 1.17.0
|
|
|
155 |
* Use the NOT() method in the Logical\Operations class instead
|
|
|
156 |
* @see Logical\Operations::NOT()
|
|
|
157 |
*
|
|
|
158 |
* @param mixed $logical A value or expression that can be evaluated to TRUE or FALSE
|
|
|
159 |
*
|
|
|
160 |
* @return array|bool|string the boolean inverse of the argument
|
|
|
161 |
*/
|
|
|
162 |
public static function NOT($logical = false)
|
|
|
163 |
{
|
|
|
164 |
return Logical\Operations::NOT($logical);
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
/**
|
|
|
168 |
* STATEMENT_IF.
|
|
|
169 |
*
|
|
|
170 |
* Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
|
|
|
171 |
*
|
|
|
172 |
* Excel Function:
|
|
|
173 |
* =IF(condition[,returnIfTrue[,returnIfFalse]])
|
|
|
174 |
*
|
|
|
175 |
* Condition is any value or expression that can be evaluated to TRUE or FALSE.
|
|
|
176 |
* For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
|
|
|
177 |
* the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
|
|
|
178 |
* This argument can use any comparison calculation operator.
|
|
|
179 |
* ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
|
|
|
180 |
* For example, if this argument is the text string "Within budget" and the condition argument
|
|
|
181 |
* evaluates to TRUE, then the IF function returns the text "Within budget"
|
|
|
182 |
* If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero).
|
|
|
183 |
* To display the word TRUE, use the logical value TRUE for this argument.
|
|
|
184 |
* ReturnIfTrue can be another formula.
|
|
|
185 |
* ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
|
|
|
186 |
* For example, if this argument is the text string "Over budget" and the condition argument
|
|
|
187 |
* evaluates to FALSE, then the IF function returns the text "Over budget".
|
|
|
188 |
* If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
|
|
|
189 |
* If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
|
|
|
190 |
* ReturnIfFalse can be another formula.
|
|
|
191 |
*
|
|
|
192 |
* @deprecated 1.17.0
|
|
|
193 |
* Use the statementIf() method in the Logical\Conditional class instead
|
|
|
194 |
* @see Logical\Conditional::statementIf()
|
|
|
195 |
*
|
|
|
196 |
* @param mixed $condition Condition to evaluate
|
|
|
197 |
* @param mixed $returnIfTrue Value to return when condition is true
|
|
|
198 |
* @param mixed $returnIfFalse Optional value to return when condition is false
|
|
|
199 |
*
|
|
|
200 |
* @return mixed The value of returnIfTrue or returnIfFalse determined by condition
|
|
|
201 |
*/
|
|
|
202 |
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
|
|
|
203 |
{
|
|
|
204 |
return Logical\Conditional::statementIf($condition, $returnIfTrue, $returnIfFalse);
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
/**
|
|
|
208 |
* STATEMENT_SWITCH.
|
|
|
209 |
*
|
|
|
210 |
* Returns corresponding with first match (any data type such as a string, numeric, date, etc).
|
|
|
211 |
*
|
|
|
212 |
* Excel Function:
|
|
|
213 |
* =SWITCH (expression, value1, result1, value2, result2, ... value_n, result_n [, default])
|
|
|
214 |
*
|
|
|
215 |
* Expression
|
|
|
216 |
* The expression to compare to a list of values.
|
|
|
217 |
* value1, value2, ... value_n
|
|
|
218 |
* A list of values that are compared to expression.
|
|
|
219 |
* The SWITCH function is looking for the first value that matches the expression.
|
|
|
220 |
* result1, result2, ... result_n
|
|
|
221 |
* A list of results. The SWITCH function returns the corresponding result when a value
|
|
|
222 |
* matches expression.
|
|
|
223 |
* default
|
|
|
224 |
* Optional. It is the default to return if expression does not match any of the values
|
|
|
225 |
* (value1, value2, ... value_n).
|
|
|
226 |
*
|
|
|
227 |
* @deprecated 1.17.0
|
|
|
228 |
* Use the statementSwitch() method in the Logical\Conditional class instead
|
|
|
229 |
* @see Logical\Conditional::statementSwitch()
|
|
|
230 |
*
|
|
|
231 |
* @param mixed $arguments Statement arguments
|
|
|
232 |
*
|
|
|
233 |
* @return mixed The value of matched expression
|
|
|
234 |
*/
|
|
|
235 |
public static function statementSwitch(...$arguments)
|
|
|
236 |
{
|
|
|
237 |
return Logical\Conditional::statementSwitch(...$arguments);
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
/**
|
|
|
241 |
* IFERROR.
|
|
|
242 |
*
|
|
|
243 |
* Excel Function:
|
|
|
244 |
* =IFERROR(testValue,errorpart)
|
|
|
245 |
*
|
|
|
246 |
* @deprecated 1.17.0
|
|
|
247 |
* Use the IFERROR() method in the Logical\Conditional class instead
|
|
|
248 |
* @see Logical\Conditional::IFERROR()
|
|
|
249 |
*
|
|
|
250 |
* @param mixed $testValue Value to check, is also the value returned when no error
|
|
|
251 |
* @param mixed $errorpart Value to return when testValue is an error condition
|
|
|
252 |
*
|
|
|
253 |
* @return mixed The value of errorpart or testValue determined by error condition
|
|
|
254 |
*/
|
|
|
255 |
public static function IFERROR($testValue = '', $errorpart = '')
|
|
|
256 |
{
|
|
|
257 |
return Logical\Conditional::IFERROR($testValue, $errorpart);
|
|
|
258 |
}
|
|
|
259 |
|
|
|
260 |
/**
|
|
|
261 |
* IFNA.
|
|
|
262 |
*
|
|
|
263 |
* Excel Function:
|
|
|
264 |
* =IFNA(testValue,napart)
|
|
|
265 |
*
|
|
|
266 |
* @deprecated 1.17.0
|
|
|
267 |
* Use the IFNA() method in the Logical\Conditional class instead
|
|
|
268 |
* @see Logical\Conditional::IFNA()
|
|
|
269 |
*
|
|
|
270 |
* @param mixed $testValue Value to check, is also the value returned when not an NA
|
|
|
271 |
* @param mixed $napart Value to return when testValue is an NA condition
|
|
|
272 |
*
|
|
|
273 |
* @return mixed The value of errorpart or testValue determined by error condition
|
|
|
274 |
*/
|
|
|
275 |
public static function IFNA($testValue = '', $napart = '')
|
|
|
276 |
{
|
|
|
277 |
return Logical\Conditional::IFNA($testValue, $napart);
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
/**
|
|
|
281 |
* IFS.
|
|
|
282 |
*
|
|
|
283 |
* Excel Function:
|
|
|
284 |
* =IFS(testValue1;returnIfTrue1;testValue2;returnIfTrue2;...;testValue_n;returnIfTrue_n)
|
|
|
285 |
*
|
|
|
286 |
* testValue1 ... testValue_n
|
|
|
287 |
* Conditions to Evaluate
|
|
|
288 |
* returnIfTrue1 ... returnIfTrue_n
|
|
|
289 |
* Value returned if corresponding testValue (nth) was true
|
|
|
290 |
*
|
|
|
291 |
* @deprecated 1.17.0
|
|
|
292 |
* Use the IFS() method in the Logical\Conditional class instead
|
|
|
293 |
* @see Logical\Conditional::IFS()
|
|
|
294 |
*
|
|
|
295 |
* @param mixed ...$arguments Statement arguments
|
|
|
296 |
*
|
|
|
297 |
* @return mixed|string The value of returnIfTrue_n, if testValue_n was true. #N/A if none of testValues was true
|
|
|
298 |
*/
|
|
|
299 |
public static function IFS(...$arguments)
|
|
|
300 |
{
|
|
|
301 |
return Logical\Conditional::IFS(...$arguments);
|
|
|
302 |
}
|
|
|
303 |
}
|