value = $value; $this->unit = $unit; } /** * Get the value * * @return float */ public function getValue(): float { return $this->value; } /** * Return the unit (e.g «degree») * * @return string */ public function getUnit(): string { return $this->unit; } /** * {@inheritDoc} */ public function diff(DiffInterface $d): int { if ($d instanceof $this) return $this->value - $d->getValue(); return 0; } public function __toString(): string { return sprintf( "%s: %f %s", basename(str_replace( '\\', DIRECTORY_SEPARATOR, get_class($this) )), $this->value, $this->unit); } }