MathParser\Parsing\Nodes\Factories\MultiplicationNodeFactory Class Reference

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

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

Public Member Functions

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

Private Member Functions

 numericFactors ($leftOperand, $rightOperand)
 Simplify a*b when a or b are certain numeric values. 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\MultiplicationNodeFactory::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 and $rightOperand are both NumberNodes, return a single NumberNode containing their product
  • If $leftOperand or $rightOperand is a NumberNode representing 0, return '0'
  • If $leftOperand or $rightOperand is a NumberNode representing 1, return the other factor
Parameters
Node | int$leftOperandFirst factor
Node | int$rightOperandSecond factor
Return values
Node

Implements MathParser\Parsing\Nodes\Interfaces\ExpressionNodeFactory.

MathParser\Parsing\Nodes\Factories\MultiplicationNodeFactory::numericFactors (   $leftOperand,
  $rightOperand 
)
private

Simplify a*b when a or b are certain numeric values.

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

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