/** * @param Query $query * * @return Converter * * @throws NotSupportedConversionException */ protected function getSupportedConverter(Query $query) : Converter { $valueUnit = $query->getValue()->getUnit(); $targetUnit = $query->getTargetUnit(); foreach ($this->converters as $converter) { if (true === $converter->isSupported($valueUnit, $targetUnit)) { return $converter; } } throw new NotSupportedConversionException($valueUnit, $targetUnit); }
/** * @inheritdoc */ public function convertFromQuery(Query $query) : Value { return $this->convertTo($query->getValue(), $query->getTargetUnit()); }