Class MathExecutor
- package NXP
Cloneable
Instantiable
Methods |
public __clone () |
public
__construct
() Base math operators |
public
addFunction
(
string
$name
,
?
callable
$function
=
NULL
,
?
int
$places
=
NULL
) :
self
|
public
addOperator
(
NXP\Classes\Operator
$operator
) :
self
|
public
clearCache
() :
void
Clear token's cache |
public
execute
(
string
$expression
,
bool
$cache
=
true
) Execute expression
|
public
getCache
() :
array
Get cache array with tokens
|
public
getFunctions
() :
array
Get all registered functions
|
public
getOperators
() Get all registered operators to executor
|
public
getVar
(
string
$variable
) Get a specific var
|
public
getVars
() :
array
Get all vars
|
public
removeVar
(
string
$variable
) :
self
|
public
removeVars
() :
self
|
public
setDivisionByZeroIsZero
() :
self
Set division by zero returns zero instead of throwing DivisionByZeroException
|
public
setVar
(
string
$variable
,
$value
) :
self
|
public
setVarNotFoundHandler
(
callable
$handler
) :
self
Define a method that will be invoked when a variable is not found. The first parameter will be the variable name, and the returned value will be used as the variable value.
|
public
setVars
(
array
$variables
,
bool
$clear
=
true
) :
self
|
Methods |
protected
addDefaults
() :
void
Set default operands and functions
|
protected
defaultFunctions
() :
array
Gets the default functions as an array. Key is function name
|
protected
defaultOperators
() :
array
Get the default operators
|
protected
defaultVars
() :
array
Returns the default variables names as key/value pairs
|
Properties |
private
$cache
|
private
$functions
|
private
$onVarNotFound
|
private
$operators
|
private
$variables
Available variables
|