public function convert($value, $fromUnit, $toUnit) {
		$fromUnit = strtoupper($fromUnit);
		$toUnit = strtoupper($toUnit);

		if (!isset($this->_units[$fromUnit]) || !isset($this->_units[$toUnit])) {
			throw new CalculatorException('Invalid Unit');
		}

		if ($fromUnit === static::UNIT_MILES) {
			$value *= $this->_units[$toUnit];
		} elseif ($toUnit === static::UNIT_MILES) {
			$value /= $this->_units[$fromUnit];
		} else {
			$value /= $this->_units[$fromUnit];
			$value *= $this->_units[$toUnit];
		}
		return $value;
	}
public function convert($value, $fromUnit, $toUnit) {
		$fromUnit = strtoupper($fromUnit);
		$toUnit = strtoupper($toUnit);

		if (!isset($this->_units[$fromUnit]) || !isset($this->_units[$toUnit])) {
			throw new CalculatorException('Invalid Unit');
		}

		if ($fromUnit === static::UNIT_MILES) {
			$value *= $this->_units[$toUnit];
		} elseif ($toUnit === static::UNIT_MILES) {
			$value /= $this->_units[$fromUnit];
		} else {
			$value /= $this->_units[$fromUnit];
			$value *= $this->_units[$toUnit];
		}
		return $value;
	}
public function convert ( $ value , $ fromUnit , $ toUnit ) { $ fromUnit = strtoupper ( $ fromUnit ) ; $ toUnit = strtoupper ( $ toUnit ) ; if ( ! isset ( $ this -> _units [ $ fromUnit ] ) || ! isset ( $ this -> _units [ $ toUnit ] ) ) { throw new CalculatorException ( 'Invalid Unit' ) ; } if ( $ fromUnit === static :: UNIT_MILES ) { $ value *= $ this -> _units [ $ toUnit ] ; } elseif ( $ toUnit === static :: UNIT_MILES ) { $ value /= $ this -> _units [ $ fromUnit ] ; } else { $ value /= $ this -> _units [ $ fromUnit ] ; $ value *= $ this -> _units [ $ toUnit ] ; } return $ value ; }
Convert between units

@param float $value
@param string $fromUnit (using class constants)
@param string $toUnit (using class constants)
@return float convertedValue
@throws \Exception
Convert between units