src/helpers/MeasureHelper.php
public static function convert($value, $to, $from)
    {
        if ($from instanceof Measure === false || $to instanceof Measure === false) {
            throw new Exception('`from` or `to` parameter is not a Measure');
        }
        if ($from->type !== $to->type) {
            throw new Exception('Measures have different types');
        }
        if ($from->id == $to->id) {
            return $value;
        }
        $converterClass = isset(static::$converters[$to->type]) === true
            ? static::$converters[$to->type]
            : 'DevGroup\Measure\converters\DefaultMeasureTypeConverter';
        return $converterClass::convert($value, $to, $from);
    }
public static function convert($value, $to, $from)
    {
        if ($from instanceof Measure === false || $to instanceof Measure === false) {
            throw new Exception('`from` or `to` parameter is not a Measure');
        }
        if ($from->type !== $to->type) {
            throw new Exception('Measures have different types');
        }
        if ($from->id == $to->id) {
            return $value;
        }
        $converterClass = isset(static::$converters[$to->type]) === true
            ? static::$converters[$to->type]
            : 'DevGroup\Measure\converters\DefaultMeasureTypeConverter';
        return $converterClass::convert($value, $to, $from);
    }
public static function convert ( $ value , $ to , $ from ) { if ( $ from instanceof Measure === false || $ to instanceof Measure === false ) { throw new Exception ( '`from` or `to` parameter is not a Measure' ) ; } if ( $ from -> type !== $ to -> type ) { throw new Exception ( 'Measures have different types' ) ; } if ( $ from -> id == $ to -> id ) { return $ value ; } $ converterClass = isset ( static :: $ converters [ $ to -> type ] ) === true ? static :: $ converters [ $ to -> type ] : 'DevGroup\Measure\converters\DefaultMeasureTypeConverter' ; return $ converterClass :: convert ( $ value , $ to , $ from ) ; }
Convert a value from one measure to another
@param float $value
@param Measure $from
@param Measure $to
@return float
@throws Exception
Convert a value from one measure to another