Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Units\UnitConverter Class Reference

Convert quantities to other units. More...

Public Member Functions

 __construct (UnitStorage $store, $entityPrefix)
 
 toStandardUnits (UnboundedQuantityValue $value)
 Convert QuantityValue to standard units. More...
 

Private Member Functions

 makeDecimalValue ( $number)
 Create DecimalValue from regular numeric string or value. More...
 

Private Attributes

 $store
 
 $math
 
 $logger
 
 $prefix
 

Detailed Description

Convert quantities to other units.

Author
Stas Malyshev

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Units\UnitConverter::__construct ( UnitStorage  $store,
  $entityPrefix 
)

Member Function Documentation

◆ makeDecimalValue()

Wikibase\Lib\Units\UnitConverter::makeDecimalValue (   $number)
private

Create DecimalValue from regular numeric string or value.

Parameters
int | float | string$numberFIXME: replace with DecimalValue method from https://github.com/DataValues/Number/pull/67
Returns
DecimalValue

◆ toStandardUnits()

Wikibase\Lib\Units\UnitConverter::toStandardUnits ( UnboundedQuantityValue  $value)

Convert QuantityValue to standard units.

Parameters
UnboundedQuantityValue$value
Returns
UnboundedQuantityValue|null Converted value in standard units, or null if no conversion possible. If the value is already in standard units, returns the original value.

Member Data Documentation

◆ $logger

Wikibase\Lib\Units\UnitConverter::$logger
private

◆ $math

Wikibase\Lib\Units\UnitConverter::$math
private

◆ $prefix

Wikibase\Lib\Units\UnitConverter::$prefix
private

◆ $store

Wikibase\Lib\Units\UnitConverter::$store
private

The documentation for this class was generated from the following file: