ConverterBuilder
Table of Contents
- $calculator : CalculatorInterface
- $defaultMeasurements : array<string|int, mixed>
- $registry : UnitRegistryInterface
- __construct() : self
- Public constructor method.
- addBinaryCalculator() : self
- Sets the converter's calculator as the binary implementation.
- addDefaultRegistry() : self
- Seeds the converter's registry with all default units provided with this package.
- addRegistryFor() : self
- Seeds the converter's registry with all units of the given measurement type that are provided with this package.
- addRegistryWith() : self
- Seeds the converter's registry with a user-defined subset of units.
- addSimpleCalculator() : self
- Set's the converter's calculator as the simple implementation provided with this package.
- build() : UnitConverter
- Retrieve a new instance of the unit converter with the configured registry & calculator.
Properties
$calculator
private
CalculatorInterface
$calculator
$defaultMeasurements
private
array<string|int, mixed>
$defaultMeasurements
$registry
private
UnitRegistryInterface
$registry
Methods
__construct()
Public constructor method.
public
__construct() : self
Return values
self —addBinaryCalculator()
Sets the converter's calculator as the binary implementation.
public
addBinaryCalculator() : self
Return values
self —addDefaultRegistry()
Seeds the converter's registry with all default units provided with this package.
public
addDefaultRegistry() : self
Return values
self —addRegistryFor()
Seeds the converter's registry with all units of the given measurement type that are provided with this package.
public
addRegistryFor(string $measurement) : self
Parameters
- $measurement : string
-
The type of measurement to seed units for.
Return values
self —addRegistryWith()
Seeds the converter's registry with a user-defined subset of units.
public
addRegistryWith([array<string|int, UnitInterface> $units = [] ]) : self
Parameters
- $units : array<string|int, UnitInterface> = []
-
An array of units to add to the registry.
Return values
self —addSimpleCalculator()
Set's the converter's calculator as the simple implementation provided with this package.
public
addSimpleCalculator() : self
Return values
self —build()
Retrieve a new instance of the unit converter with the configured registry & calculator.
public
build() : UnitConverter