class Math (View source)

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

int evaluate(string $string)

Parses and executes given formula

Parameters

string $string

Formula to process

Return Value

int

void parse(string $string)

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

Parameters

string $string

Formula to process

Return Value

void

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

int run()

Executes currently parsed formula with current variables

Return Value

int

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

No description

Parameters

Expression $expression
Stack $output
Stack $operators

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

No description

Parameters

Expression $expression
Stack $output
Stack $operators

protected tokenize($string)

No description

Parameters

$string