UnitRegistryInterface
The interface for the unit converter registry that stores units and types of measurement.
Tags
Table of Contents
- isMeasurementRegistered() : bool
- Determine if a measurement type is registered to the unit registry or not.
- isUnitRegistered() : bool
- Determine if a specific unit of measure is registered to the unit registry or not.
- listMeasurements() : array<string|int, mixed>
- Return a one-dimensional array of currently supported measurement types.
- listUnits() : array<string|int, mixed>
- Return a one-dimensional array of currently supported units. Optionally pass a string equal to a type of measurement (e.g. "length") to return only units of the specifed type.
- loadUnit() : null|UnitInterface
- Fetch a unit from the unit registry for use elsewhere.
- registerMeasurement() : void
- Register a single measurement to the unit registry by passing a string as the argument
- registerMeasurements() : void
- Register many measurements to the unit registry by passing an array of measurement strings as the argument
- registerUnit() : void
- Register a single unit to the unit registry by passing an instance of a UnitInterface as it's argument
- registerUnits() : void
- Register many units to the unit registry by passing an array of unit classes as it's argument.
- unregisterMeasurement() : void
- Unegister a single measurement from the unit registry.
- unregisterMeasurements() : void
- Unegister many units from the unit registry
- unregisterUnit() : void
- Unegister a single unit from the unit registry
- unregisterUnits() : void
- Unegister many units from the unit registry
Methods
isMeasurementRegistered()
Determine if a measurement type is registered to the unit registry or not.
public
isMeasurementRegistered(string $measurement) : bool
Parameters
- $measurement : string
-
The name of the measurment being checked, e.g. "length".
Return values
bool —isUnitRegistered()
Determine if a specific unit of measure is registered to the unit registry or not.
public
isUnitRegistered(string $symbol) : bool
Parameters
- $symbol : string
-
The symbol notation of the unit being checked, e.g., "cm".
Return values
bool —listMeasurements()
Return a one-dimensional array of currently supported measurement types.
public
listMeasurements() : array<string|int, mixed>
Return values
array<string|int, mixed> —listUnits()
Return a one-dimensional array of currently supported units. Optionally pass a string equal to a type of measurement (e.g. "length") to return only units of the specifed type.
public
listUnits([string $measurement = null ]) : array<string|int, mixed>
Parameters
- $measurement : string = null
Return values
array<string|int, mixed> —loadUnit()
Fetch a unit from the unit registry for use elsewhere.
public
loadUnit(string $symbol) : null|UnitInterface
Parameters
- $symbol : string
-
The symbol notation of the unit being loaded.
Tags
Return values
null|UnitInterface —registerMeasurement()
Register a single measurement to the unit registry by passing a string as the argument
public
registerMeasurement(string $measurement) : void
Parameters
- $measurement : string
Tags
Return values
void —registerMeasurements()
Register many measurements to the unit registry by passing an array of measurement strings as the argument
public
registerMeasurements(array<string|int, mixed> $measurements) : void
Parameters
- $measurements : array<string|int, mixed>
Return values
void —registerUnit()
Register a single unit to the unit registry by passing an instance of a UnitInterface as it's argument
public
registerUnit(UnitInterface $unit) : void
Parameters
- $unit : UnitInterface
Tags
Return values
void —registerUnits()
Register many units to the unit registry by passing an array of unit classes as it's argument.
public
registerUnits(array<string|int, UnitInterface> $units) : void
Parameters
- $units : array<string|int, UnitInterface>
Return values
void —unregisterMeasurement()
Unegister a single measurement from the unit registry.
public
unregisterMeasurement(string $symbol) : void
Parameters
- $symbol : string
Tags
Return values
void —unregisterMeasurements()
Unegister many units from the unit registry
public
unregisterMeasurements(array<string|int, string> $symbols) : void
Parameters
- $symbols : array<string|int, string>
Return values
void —unregisterUnit()
Unegister a single unit from the unit registry
public
unregisterUnit(string $symbol) : void
Parameters
- $symbol : string
Tags
Return values
void —unregisterUnits()
Unegister many units from the unit registry
public
unregisterUnits(array<string|int, string> $symbols) : void
Parameters
- $symbols : array<string|int, string>