class Math

Core class of the library performing parsing and calculations.

Properties

protected $variables
protected $stack

Methods

int
evaluate(string $string)

Parses and executes given formula

void
parse(string $string)

Parses given formula. The parsed formula is stored in the class.

void
registerVariable(string $name, int $value)

Registers variable for use withing calculation

int
run()

Executes currently parsed formula with current variables

parseParenthesis(Expression $expression, Stack $output, Stack $operators)

No description

parseOperator(Expression $expression, Stack $output, Stack $operators)

No description

tokenize($string)

No description

Details

at line 39
int evaluate(string $string)

Parses and executes given formula

Parameters

string $string Formula to process

Return Value

int

at line 52
void parse(string $string)

Parses given formula. The parsed formula is stored in the class.

Parameters

string $string Formula to process

Return Value

void

at line 83
void registerVariable(string $name, int $value)

Registers variable for use withing calculation

Parameters

string $name Name of variable
int $value Value of variable

Return Value

void

at line 92
int run()

Executes currently parsed formula with current variables

Return Value

int

at line 103
protected parseParenthesis(Expression $expression, Stack $output, Stack $operators)

Parameters

Expression $expression
Stack $output
Stack $operators

at line 122
protected parseOperator(Expression $expression, Stack $output, Stack $operators)

Parameters

Expression $expression
Stack $output
Stack $operators

at line 142
protected tokenize($string)

Parameters

$string