public function equals(Converter $that) { if (!$that instanceof self) { return false; } return $this->dividend == $that->getDividend() && $this->divisor == $that->getDivisor(); }
public function equals(Converter $that) { if (!$that instanceof self) { return false; } return $this->offset == $that->getOffset(); }
public function equals(Converter $that) { if (!$that instanceof self) { return false; } return $this->base == $that->getBase(); }
public function equals(Converter $that) { if (!$that instanceof self) { return false; } return $this->factor == $that->getFactor(); }
public function toBaseUnits() { $result = Converter::IDENTITY(); foreach ($this->elements as $element) { $unit = $element->unit; $converter = $unit->toBaseUnits(); if (!$converter->isLinear()) { throw new \RuntimeException($unit->getSymbol() . ' is non-linear.'); } if ($element->root != 1) { throw new \RuntimeException($unit->getSymbol() . ' holds a base unit with fractional exponent'); } $pow = $element->pow; if ($pow < 0) { $pow = -$pow; $converter = $converter->inverse(); } for ($j = 0; $j < $pow; ++$j) { $result = $result->concat($converter); } } return $result; }
/** * Applies the given operation and returns a transformed unit. * * @param Converter $operation * * @return Unit */ protected function transform(Converter $operation) { if ($operation->isIdentity()) { return $this; } return new TransformedUnit($this, $operation); }
public function __toString() { return $this->first->__toString() . $this->second->__toString(); }
public function toBaseUnits() { return Converter::IDENTITY(); }
public function toStandardUnit() { return Converter::IDENTITY(); }