Documentation

UnitRegistry implements UnitRegistryInterface

The unit converter registry object. This object is used to store and retrieve instances of the UnitInterface.

Tags
version
1.0.0
since
0.0.1
author

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

Interfaces, Classes and Traits

UnitRegistryInterface
The interface for the unit converter registry that stores units and types of measurement.

Table of Contents

$store  : Collection
__construct()  : self
Public constructor function for the unit registry.
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

Properties

Methods

__construct()

Public constructor function for the unit registry.

public __construct([array<string|int, UnitInterface$units = [] ]) : self
Parameters
$units : array<string|int, UnitInterface> = []

A one-dimensional array of UnitInterface objects to be registered upon construction.

Return values
self

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.

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
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
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, mixed> $units) : void
Parameters
$units : array<string|int, mixed>
Return values
void

unregisterMeasurement()

Unegister a single measurement from the unit registry.

public unregisterMeasurement(string $measurement) : void
Parameters
$measurement : string
Return values
void

unregisterMeasurements()

Unegister many units from the unit registry

public unregisterMeasurements(array<string|int, mixed> $measurements) : void
Parameters
$measurements : array<string|int, mixed>
Return values
void

unregisterUnit()

Unegister a single unit from the unit registry

public unregisterUnit(string $symbol) : void
Parameters
$symbol : string
Return values
void

unregisterUnits()

Unegister many units from the unit registry

public unregisterUnits(array<string|int, mixed> $symbols) : void
Parameters
$symbols : array<string|int, mixed>
Return values
void

Search results