Conditional
in package
uses
ArrayEnabled
Table of Contents
Properties
Methods
- IFERROR() : mixed
- IFERROR.
- IFNA() : mixed
- IFNA.
- IFS() : mixed|string
- IFS.
- statementIf() : mixed
- STATEMENT_IF.
- statementSwitch() : mixed
- STATEMENT_SWITCH.
- evaluateArrayArguments() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.
- evaluateArrayArgumentsIgnore() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.
- evaluateArrayArgumentsSubset() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.
- evaluateArrayArgumentsSubsetFrom() : array<string|int, mixed>
- Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.
- evaluateSingleArgumentArray() : array<string|int, mixed>
- Handles array argument processing when the function accepts a single argument that can be an array argument.
- initialiseHelper() : void
- testFalse() : bool
Properties
$arrayArgumentHelper
private
static ArrayArgumentHelper
$arrayArgumentHelper
$initializationNeeded
private
static bool
$initializationNeeded
= true
Methods
IFERROR()
IFERROR.
public
static IFERROR([mixed $testValue = '' ][, mixed $errorpart = '' ]) : mixed
Excel Function: =IFERROR(testValue,errorpart)
Parameters
- $testValue : mixed = ''
-
Value to check, is also the value returned when no error Or can be an array of values
- $errorpart : mixed = ''
-
Value to return when testValue is an error condition Note that this can be an array value to be returned
Return values
mixed —The value of errorpart or testValue determined by error condition If an array of values is passed as the $testValue argument, then the returned result will also be an array with the same dimensions
IFNA()
IFNA.
public
static IFNA([mixed $testValue = '' ][, mixed $napart = '' ]) : mixed
Excel Function: =IFNA(testValue,napart)
Parameters
- $testValue : mixed = ''
-
Value to check, is also the value returned when not an NA Or can be an array of values
- $napart : mixed = ''
-
Value to return when testValue is an NA condition Note that this can be an array value to be returned
Return values
mixed —The value of errorpart or testValue determined by error condition If an array of values is passed as the $testValue argument, then the returned result will also be an array with the same dimensions
IFS()
IFS.
public
static IFS(mixed ...$arguments) : mixed|string
Excel Function: =IFS(testValue1;returnIfTrue1;testValue2;returnIfTrue2;...;testValue_n;returnIfTrue_n)
testValue1 ... testValue_n Conditions to Evaluate returnIfTrue1 ... returnIfTrue_n Value returned if corresponding testValue (nth) was true
Parameters
- $arguments : mixed
-
Statement arguments Note that this can be an array value to be returned
Return values
mixed|string —The value of returnIfTrue_n, if testValue_n was true. #N/A if none of testValues was true
statementIf()
STATEMENT_IF.
public
static statementIf([mixed $condition = true ][, mixed $returnIfTrue = 0 ][, mixed $returnIfFalse = false ]) : mixed
Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.
Excel Function: =IF(condition[,returnIfTrue[,returnIfFalse]])
Condition is any value or expression that can be evaluated to TRUE or FALSE.
For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100,
the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE.
This argument can use any comparison calculation operator.
ReturnIfTrue is the value that is returned if condition evaluates to TRUE.
For example, if this argument is the text string "Within budget" and
the condition argument evaluates to TRUE, then the IF function returns the text "Within budget"
If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero).
To display the word TRUE, use the logical value TRUE for this argument.
ReturnIfTrue can be another formula.
ReturnIfFalse is the value that is returned if condition evaluates to FALSE.
For example, if this argument is the text string "Over budget" and the condition argument evaluates
to FALSE, then the IF function returns the text "Over budget".
If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned.
If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned.
ReturnIfFalse can be another formula.
Parameters
- $condition : mixed = true
-
Condition to evaluate
- $returnIfTrue : mixed = 0
-
Value to return when condition is true Note that this can be an array value
- $returnIfFalse : mixed = false
-
Optional value to return when condition is false Note that this can be an array value
Return values
mixed —The value of returnIfTrue or returnIfFalse determined by condition
statementSwitch()
STATEMENT_SWITCH.
public
static statementSwitch(mixed ...$arguments) : mixed
Returns corresponding with first match (any data type such as a string, numeric, date, etc).
Excel Function: =SWITCH (expression, value1, result1, value2, result2, ... value_n, result_n [, default])
Expression
The expression to compare to a list of values.
value1, value2, ... value_n
A list of values that are compared to expression.
The SWITCH function is looking for the first value that matches the expression.
result1, result2, ... result_n
A list of results. The SWITCH function returns the corresponding result when a value
matches expression.
Note that these can be array values to be returned
default
Optional. It is the default to return if expression does not match any of the values
(value1, value2, ... value_n).
Note that this can be an array value to be returned
Parameters
- $arguments : mixed
-
Statement arguments
Return values
mixed —The value of matched expression
evaluateArrayArguments()
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument.
protected
static evaluateArrayArguments(callable $method, mixed ...$arguments) : array<string|int, mixed>
Example use for: ROUND() or DATE().
Parameters
- $method : callable
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsIgnore()
Handles array argument processing when the function accepts multiple arguments, and any of them can be an array argument except for the one specified by ignore.
protected
static evaluateArrayArgumentsIgnore(callable $method, int $ignore, mixed ...$arguments) : array<string|int, mixed>
Example use for: HLOOKUP() and VLOOKUP(), where argument 1 is a matrix that needs to be treated as a database rather than as an array argument.
Parameters
- $method : callable
- $ignore : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsSubset()
Handles array argument processing when the function accepts multiple arguments, but only the first few (up to limit) can be an array arguments.
protected
static evaluateArrayArgumentsSubset(callable $method, int $limit, mixed ...$arguments) : array<string|int, mixed>
Example use for: NETWORKDAYS() or CONCATENATE(), where the last argument is a matrix (or a series of values) that need to be treated as a such rather than as an array arguments.
Parameters
- $method : callable
- $limit : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateArrayArgumentsSubsetFrom()
Handles array argument processing when the function accepts multiple arguments, but only the last few (from start) can be an array arguments.
protected
static evaluateArrayArgumentsSubsetFrom(callable $method, int $start, mixed ...$arguments) : array<string|int, mixed>
Example use for: Z.TEST() or INDEX(), where the first argument 1 is a matrix that needs to be treated as a dataset rather than as an array argument.
Parameters
- $method : callable
- $start : int
- $arguments : mixed
Return values
array<string|int, mixed>evaluateSingleArgumentArray()
Handles array argument processing when the function accepts a single argument that can be an array argument.
protected
static evaluateSingleArgumentArray(callable $method, array<string|int, mixed> $values) : array<string|int, mixed>
Example use for: DAYOFMONTH() or FACT().
Parameters
- $method : callable
- $values : array<string|int, mixed>
Return values
array<string|int, mixed>initialiseHelper()
private
static initialiseHelper(array<string|int, mixed>|false $arguments) : void
Parameters
- $arguments : array<string|int, mixed>|false
-
Can be changed to array for Php8.1+
testFalse()
private
static testFalse(mixed $value) : bool
Parameters
- $value : mixed