Class op
Operator utilities
To get started, place the following line around top of your code.
use amekusa\plz\op;
Methods summary
public static
boolean
|
#
eq( mixed $X, mixed $Y )
Returns whether or not $X equals $Y
Returns whether or not $X equals $Y
Parameters
Returns
boolean
|
public static
boolean
|
#
any( mixed[*] $Conditions )
Returns whether any one of conditions supplied is truthy
Returns whether any one of conditions supplied is truthy
If only 1 argument is passed and it is iterable,
checks whether any one of its elements is truthy.
Parameters
Returns
boolean
Example
Demonstration
$var1 = 0;
$var2 = null;
$var3 = 'string';
var_dump( op::any($var1, $var2) );
var_dump( op::any($var1, $var2, $var3) );
bool(false)
bool(true)
Checking iterable elements
$var1 = array (
0,
null,
'string'
);
$var2 = array (
0,
null,
false
);
var_dump( op::any($var1) );
var_dump( op::any($var2) );
bool(true)
bool(false)
|
public static
boolean
|
#
all( mixed[*] $Conditions )
Returns whether all of conditions supplied is truthy
Returns whether all of conditions supplied is truthy
If only 1 argument is passed and it is iterable,
checks whether all of its elements is truthy.
Parameters
Returns
boolean
Example
Demonstration
$var1 = 1;
$var2 = true;
$var3 = null;
var_dump( op::all($var1, $var2) );
var_dump( op::all($var1, $var2, $var3) );
bool(true)
bool(false)
Checking iterable elements
$var1 = array (
1,
true,
null
);
$var2 = array (
1,
true,
'string'
);
var_dump( op::all($var1) );
var_dump( op::all($var2) );
bool(false)
bool(true)
|