You are here

function units_converters_linear in Units of Measurement 7

Units convert callback for linear dependency logic.

Handle cases, when it is linear dependency between units.

Parameters

float $value: Value in $from units that should be converted into $to units

Entity $from: Units entity in which $value is represented

Entity $to: Units entity into which $value should be converted

Return value

float $value converted into $to units

1 string reference to 'units_converters_linear'
linear.inc in plugins/converters/linear.inc

File

plugins/converters/linear.inc, line 29

Code

function units_converters_linear($value, $from, $to) {

  // We use 'factor' property to convert value firstly to SI unit measure from
  // $from units, and then from SI units we convert it into $to units.
  $si_value = $value * $from->factor;
  return $si_value / $to->factor;
}