/** * Convert this quantity to the given unit of measure. * * @param UnitOfMeasureInterface $unit The object representing the target unit of measure. * * @return PhysicalQuantity This quantity's value in the given unit of measure. */ private function toUnitOfMeasure(UnitOfMeasureInterface $unit) { $thisValueInNativeUnit = $this->toNativeUnit()->getValue(); return new static($unit->convertValueFromNativeUnitOfMeasure($thisValueInNativeUnit), $unit->getName()); }
/** * Convert this quantity to the given unit of measure. * * @param UnitOfMeasureInterface $unit The object representing the target unit of measure. * * @return float This quantity's value in the given unit of measure. */ private function toUnitOfMeasure(UnitOfMeasureInterface $unit) { $thisValueInNativeUnit = $this->toNativeUnit(); return $unit->convertValueFromNativeUnitOfMeasure($thisValueInNativeUnit); }