Documentation

UnitConverterInterface

The interface for any and all unit converter classes.

Tags
version
1.0.0
since
0.0.1
author

Jordan Brauer 18744334+jordanbrauer@users.noreply.github.com

codeCoverageIgnore

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
example
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
example
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.

Tags
example
Return values
int|float|string

Search results