UnitConverterInterface
The interface for any and all unit converter classes.
Tags
Table of Contents
- convert() : UnitConverterInterface
- Set the unit converters' value to be converted. This method is the first method to be called in the chain of conversion methods.
- from() : UnitConverterInterface
- Set the unit converters' unit to be converted **from**. This method is the second to be called in the chain of conversion methods.
- to() : int|float|string
- Set the unit converters' unit to be converted **to**. This method is the third to be called in the chain of conversion methods.
Methods
convert()
Set the unit converters' value to be converted. This method is the first method to be called in the chain of conversion methods.
public
convert(int|float|string $value[, int $precision = null ]) : UnitConverterInterface
Parameters
- $value : int|float|string
-
The numerical value being converted.
- $precision : int = null
-
The decimal precision to be rounded to
Tags
Return values
UnitConverterInterface —from()
Set the unit converters' unit to be converted **from**. This method is the second to be called in the chain of conversion methods.
public
from(string $unit) : UnitConverterInterface
Parameters
- $unit : string
-
The unit being conerted from. The unit must first be registered to the UnitRegistry.
Tags
Return values
UnitConverterInterface —to()
Set the unit converters' unit to be converted **to**. This method is the third to be called in the chain of conversion methods.
public
to(string $unit) : int|float|string
Parameters
- $unit : string
-
The unit being converted to. The unit must first be registered to the UnitRegistry.