ArithmeticOperator uses ConstantsTrait
Enumeration of common arithmetic operator symbols as string constants.
This class provides symbolic names for basic arithmetic operations, facilitating clearer, self-documenting code when performing or representing arithmetic computations in string form.
Operators Included:
- Addition (
+) - Subtraction (
-) - Multiplication (
*) - Division (
/) - Modulo (
%) - Exponentiation (
**)
Usage Example:
use oihana\enums\ArithmeticOperator;
$expression = "3 " . ArithmeticOperator::ADDITION . " 4"; // "3 + 4"
$power = "2 " . ArithmeticOperator::EXPONENT . " 8"; // "2 ** 8"
Features:
- Constants defined as strings representing the actual operator symbols.
- Uses
ConstantsTraitfor reflection capabilities or retrieving constants dynamically. - Useful in expression builders, parsers, or any code that manipulates arithmetic operators symbolically.
Tags
Table of Contents
Constants
- ADDITION : string = "+"
- DIVISION : string = "/"
- EXPONENT : string = "**"
- MODULO : string = "%"
- MULTIPLICATION : string = "*"
- SUBSTRACTION : string = "-"
Constants
ADDITION
public
string
ADDITION
= "+"
DIVISION
public
string
DIVISION
= "/"
EXPONENT
public
string
EXPONENT
= "**"
MODULO
public
string
MODULO
= "%"
MULTIPLICATION
public
string
MULTIPLICATION
= "*"
SUBSTRACTION
public
string
SUBSTRACTION
= "-"