TemperatureFormula extends AbstractFormula
Abstract formula for all other temperature formula to extend. Common methods are contained here.
Tags
Table of Contents
- FORMULA_STRING = ''
- The string representation of the formula.
- FORMULA_TEMPLATE = ''
- The template of the formula for casting to a string after running an operation.
- ZERO_C_TO_K = 273.15
- The value of absolute zero degrees Celsius in Kelvin. Useful for converting Kelvin values.
- $calculator : CalculatorInterface
- The calculator to run the formula through.
- $values : array<string|int, mixed>
- A one-dimensional array of values to plug into the formula template when this formula is casted to a string.
- __construct() : self
- Public constructor method.
- __toString() : string
- Return the string representation of this object.
- describe() : int|float|string
- Return the result of a mathematical expression, representing an amount of units.
- setCalculator() : FormulaInterface
- Explicitly sets the calculator for a formula.
- fahrenheit() : int|float|string
- A common method for fahrenheit conversions.
- plugVariables() : void
- Set the values (passed _**in order**_) to be used for the template for logging a complete version of the formula.
Constants
FORMULA_STRING
The string representation of the formula.
public
mixed
FORMULA_STRING
= ''
Tags
FORMULA_TEMPLATE
The template of the formula for casting to a string after running an operation.
public
mixed
FORMULA_TEMPLATE
= ''
Tags
ZERO_C_TO_K
The value of absolute zero degrees Celsius in Kelvin. Useful for converting Kelvin values.
public
mixed
ZERO_C_TO_K
= 273.15
Properties
$calculator
The calculator to run the formula through.
protected
CalculatorInterface
$calculator
$values
A one-dimensional array of values to plug into the formula template when this formula is casted to a string.
protected
array<string|int, mixed>
$values
= []
Methods
__construct()
Public constructor method.
public
__construct([CalculatorInterface $calculator = null ]) : self
Parameters
- $calculator : CalculatorInterface = null
Return values
self —__toString()
Return the string representation of this object.
public
__toString() : string
Return values
string —describe()
Return the result of a mathematical expression, representing an amount of units.
public
abstract describe(mixed $value, mixed $fromUnits, mixed $toUnits[, int $precision = null ]) : int|float|string
Parameters
- $value : mixed
- $fromUnits : mixed
- $toUnits : mixed
- $precision : int = null
Return values
int|float|string —setCalculator()
Explicitly sets the calculator for a formula.
public
setCalculator(CalculatorInterface $calculator) : FormulaInterface
Parameters
- $calculator : CalculatorInterface
-
The calculator that will be set for describing values.
Return values
FormulaInterface —fahrenheit()
A common method for fahrenheit conversions.
protected
final fahrenheit(int|float|string $value, int $precision, string $polarity) : int|float|string
Parameters
- $value : int|float|string
- $precision : int
- $polarity : string
-
A valid calculator method for positive/negative operations.
Return values
int|float|string —plugVariables()
Set the values (passed _**in order**_) to be used for the template for logging a complete version of the formula.
protected
plugVariables(mixed ...$variables) : void
Parameters
- $variables : mixed
-
A variadic set of arguments, passed in order to fill the template with.