CalculatedNumberUtil Class Reference

Static Public Member Functions

static calculateByFormulaAndModelAndResolveFormat ($formula, RedBeanModel $model)
static calculateByFormulaAndModel ($formula, RedBeanModel $model, &$formatType, &$currencyCode)
static isFormulaValid ($formula, $modelClassName)

Data Fields

const FORMAT_TYPE_INTEGER = 1
const FORMAT_TYPE_DECIMAL = 2
const FORMAT_TYPE_CURRENCY_VALUE = 3

Static Protected Member Functions

static calculateByExpressionAndModel ($expression, RedBeanModel $model, &$formatType, &$currencyCode)
static getIfStatementParts ($formula)
static getConditionParts ($condition)
static isExpressionValid ($expression, $modelClassName)
static isString ($expression)
static isAttribute ($expression, $modelClassName)
static isConditionValid ($condition, $modelClassName)
static isIfStatementValid ($condition, $trueExpression, $falseExpression, $modelClassName)
static mathEval ($equation)
static resolveFormatTypeAndCurrencyCode (&$formatType, &$currencyCode, $model, $attribute)

Detailed Description

Helper class to work with calculated numbers.

Definition at line 40 of file CalculatedNumberUtil.php.


Member Function Documentation

static calculateByFormulaAndModelAndResolveFormat ( formula,
RedBeanModel model 
) [static]

Calculate the formula and resolve the correct formula based on the attributes included in the formula

Parameters:
$formula 
RedBeanModel $model
Returns:
mixed
Exceptions:
NotSupportedException 

Definition at line 55 of file CalculatedNumberUtil.php.

static calculateByFormulaAndModel ( formula,
RedBeanModel model,
&$  formatType,
&$  currencyCode 
) [static]

Given a formula string and a model, calculate the number using the formula and values from the attributes on the model.

Parameters:
string $formula
RedBeanModel $model
$formatType 
$currencyCode 
Returns:
bool|int|string calculated value as number.

Definition at line 91 of file CalculatedNumberUtil.php.

static isFormulaValid ( formula,
modelClassName 
) [static]

Given a formula string and a model, determine if the formula is correctly formed and is using valid attributes from the given model.

Parameters:
$formula 
$modelClassName 
Returns:
bool

Definition at line 205 of file CalculatedNumberUtil.php.


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables
Generated on Mon Nov 20 07:10:22 2017