예제 #1
0
 /**
  * @inheritdoc
  */
 protected function calculateValue(Value $value, Unit $targetUnit) : Value
 {
     $conversionMap = $targetUnit->getConvertUnitMap();
     $valueToConvert = $value->getValue();
     $valueUnitValue = $conversionMap[(string) $value->getUnit()];
     $targetUnitValue = $conversionMap[(string) $targetUnit];
     $convertedValue = bcdiv(bcmul($valueToConvert, $targetUnitValue, 5), $valueUnitValue, 2);
     return new Value($convertedValue, $targetUnit);
 }
 public function __construct(Unit $valueUnit, Unit $targetUnit)
 {
     parent::__construct(sprintf(static::ERROR_MESSAGE, $valueUnit->getName(), $targetUnit->getName()));
 }