MathParser\Parsing\Nodes\Factories\DivisionNodeFactory Class Reference

Factory for creating an ExpressionNode representing '/'. More...

Inheritance diagram for MathParser\Parsing\Nodes\Factories\DivisionNodeFactory:
MathParser\Parsing\Nodes\Interfaces\ExpressionNodeFactory

Public Member Functions

 makeNode ($leftOperand, $rightOperand)
 Create a Node representing '$leftOperand/$rightOperand'. More...
 

Protected Member Functions

 numericFactors ($leftOperand, $rightOperand)
 Simplify division nodes when factors are numeric. More...
 

Detailed Description

Factory for creating an ExpressionNode representing '/'.

Some basic simplification is applied to the resulting Node.

Member Function Documentation

MathParser\Parsing\Nodes\Factories\DivisionNodeFactory::makeNode (   $leftOperand,
  $rightOperand 
)

Create a Node representing '$leftOperand/$rightOperand'.

Using some simplification rules, create a NumberNode or ExpressionNode giving an AST correctly representing '$leftOperand/$rightOperand'.

Simplification rules:

  • To simplify the use of the function, convert integer params to NumberNodes
  • If $leftOperand is a NumberNode representing 0, return 0
  • If $rightOperand is a NumberNode representing 1, return $leftOperand
  • If $leftOperand and $rightOperand are equal, return '1'
Parameters
Node | int$leftOperandNumerator
Node | int$rightOperandDenominator
Return values
Node

Implements MathParser\Parsing\Nodes\Interfaces\ExpressionNodeFactory.

MathParser\Parsing\Nodes\Factories\DivisionNodeFactory::numericFactors (   $leftOperand,
  $rightOperand 
)
protected

Simplify division nodes when factors are numeric.

Parameters
Node$leftOperand
Node$rightOperand
Return values
Node|null

The documentation for this class was generated from the following file: