SquareMetre extends AreaUnit
Square metre data class. All area units will use this class as the $base property.
Tags
Table of Contents
- RESERVED_FORMULA = '*'
- $base : string|UnitInterface
- $formulae : array<string|int, mixed>
- An array of formulae for this unit to convert itself with.
- $name : string
- $scientificSymbol : string
- $symbol : string
- $unitOf : string
- $units : float
- $value : int|float|string
- __construct() : mixed
- Public constructor function for units of measurement.
- __toString() : string
- String representation of a unit used for unique sorting.
- addFormula() : void
- Add a new formula to the unit.
- addFormulae() : void
- Add multiple formulae to the unit.
- as() : int|float|string
- Convenience method that converts the current unit to whatever unit is passed in. Optionally supply precision & whether or not to use a binary calculator (BCMath).
- getBase() : UnitInterface
- Returns the unit class that this unit is based off of.
- getBaseUnits() : float
- Returns the units base unit units'.
- getFormulaFor() : null|FormulaInterface
- Return a unit's conversion formula, if it has one.
- getName() : string
- Returns the full symantic name of the unit.
- getRegistryKey() : string|null
- Returns the unit's registry key.
- getScientificSymbol() : string
- Returns the symbol notation of the unit.
- getSymbol() : string
- Returns the symbol notation of the unit.
- getUnitOf() : string
- Returns the type of measurement that this unit is measuring.
- getUnits() : float
- Returns the amount of base units required to make up 1 of the unit.
- getValue() : int|float|string
- Returns the unit's numeric value (how many of it there are).
- isMultipleSiUnit() : bool
- Is the unit an SI multiple unit?
- isSiUnit() : bool
- Is the unit an SI base unit?
- isSubmultipleSiUnit() : bool
- Is the unit an SI submultiple unit?
- setBase() : UnitInterface
- Sets the unit class that this unit is based off of.
- setName() : UnitInterface
- Sets the units full symantic name.
- setScientificSymbol() : UnitInterface
- Sets the unicode scientific symbol notation used for the unit.
- setSymbol() : UnitInterface
- Sets the symbol notation used for the unit.
- setUnitOf() : UnitInterface
- Sets the type of measurement that this unit is measuring.
- setUnits() : UnitInterface
- Sets the amount of base units required to make up 1 of the unit.
- setValue() : UnitInterface
- Sets the unit's numeric value (how many of it are there?).
- configure() : void
Constants
RESERVED_FORMULA
private
mixed
RESERVED_FORMULA
= '*'
Properties
$base
protected
string|UnitInterface
$base
$formulae
An array of formulae for this unit to convert itself with.
protected
array<string|int, mixed>
$formulae
$name
protected
string
$name
$scientificSymbol
protected
string
$scientificSymbol
$symbol
protected
string
$symbol
$unitOf
protected
string
$unitOf
$units
protected
float
$units
$value
protected
int|float|string
$value
Methods
__construct()
Public constructor function for units of measurement.
public
__construct([int|float|string $value = 1 ]) : mixed
Parameters
- $value : int|float|string = 1
-
The amount of units to be reprsented by the final object as.
Return values
mixed —__toString()
String representation of a unit used for unique sorting.
public
__toString() : string
Return values
string —addFormula()
Add a new formula to the unit.
public
addFormula(string $symbol, string $class) : void
Parameters
- $symbol : string
-
The symbol of the unit to use for identifying the formula.
- $class : string
-
The class name (FQCN) of formula implementation.
Return values
void —addFormulae()
Add multiple formulae to the unit.
public
addFormulae(array<string|int, mixed> $formulae) : void
Parameters
- $formulae : array<string|int, mixed>
-
An associative array containing the symbol & class.
Return values
void —as()
Convenience method that converts the current unit to whatever unit is passed in. Optionally supply precision & whether or not to use a binary calculator (BCMath).
public
as(UnitInterface $unit[, int $precision = null ][, bool $binary = false ]) : int|float|string
Parameters
- $unit : UnitInterface
-
An instance of the unit being converted to.
- $precision : int = null
-
The precision to calculate to.
- $binary : bool = false
-
Are we using BCMath?
Return values
int|float|string —getBase()
Returns the unit class that this unit is based off of.
public
getBase() : UnitInterface
Return values
UnitInterface —getBaseUnits()
Returns the units base unit units'.
public
getBaseUnits() : float
Return values
float —getFormulaFor()
Return a unit's conversion formula, if it has one.
public
getFormulaFor(UnitInterface $to) : null|FormulaInterface
Parameters
- $to : UnitInterface
-
The unit being converted to.
Return values
null|FormulaInterface —getName()
Returns the full symantic name of the unit.
public
getName() : string
Return values
string —getRegistryKey()
Returns the unit's registry key.
public
getRegistryKey() : string|null
Return values
string|null —getScientificSymbol()
Returns the symbol notation of the unit.
public
getScientificSymbol() : string
Return values
string —getSymbol()
Returns the symbol notation of the unit.
public
getSymbol() : string
Return values
string —getUnitOf()
Returns the type of measurement that this unit is measuring.
public
getUnitOf() : string
Return values
string —getUnits()
Returns the amount of base units required to make up 1 of the unit.
public
getUnits() : float
Return values
float —getValue()
Returns the unit's numeric value (how many of it there are).
public
getValue() : int|float|string
Return values
int|float|string —isMultipleSiUnit()
Is the unit an SI multiple unit?
public
isMultipleSiUnit() : bool
Return values
bool —isSiUnit()
Is the unit an SI base unit?
public
isSiUnit() : bool
Return values
bool —isSubmultipleSiUnit()
Is the unit an SI submultiple unit?
public
isSubmultipleSiUnit() : bool
Return values
bool —setBase()
Sets the unit class that this unit is based off of.
public
setBase(mixed $base) : UnitInterface
Parameters
- $base : mixed
-
The class that the unit is based on.
Return values
UnitInterface —setName()
Sets the units full symantic name.
public
setName(string $name) : UnitInterface
Parameters
- $name : string
-
The value to be set as the units name
Return values
UnitInterface —setScientificSymbol()
Sets the unicode scientific symbol notation used for the unit.
public
setScientificSymbol(string $scientificSymbol) : UnitInterface
Parameters
- $scientificSymbol : string
-
The unicode character to be set as the units scientific symbol
Return values
UnitInterface —setSymbol()
Sets the symbol notation used for the unit.
public
setSymbol(string $symbol) : UnitInterface
Parameters
- $symbol : string
-
The value to be set as the units symbol
Return values
UnitInterface —setUnitOf()
Sets the type of measurement that this unit is measuring.
public
setUnitOf(string $unitOf) : UnitInterface
Parameters
- $unitOf : string
-
The value to be set as the units governing unit
Return values
UnitInterface —setUnits()
Sets the amount of base units required to make up 1 of the unit.
public
setUnits(float $units) : UnitInterface
Parameters
- $units : float
-
The amount of units required to make a single base unit
Return values
UnitInterface —setValue()
Sets the unit's numeric value (how many of it are there?).
public
setValue(mixed $value) : UnitInterface
Parameters
- $value : mixed
-
The numeric value to use.
Return values
UnitInterface —configure()
protected
configure() : void