name = (string)$xml['name']; } /** * {@inheritDoc} * @todo Support conversion from other types, not just mps */ public function convertTo(string $unit): ConvertableInterface { switch ($unit) { case self::UNIT_KNOTS: return $this->mul(new CustomUnit(1.9438445, $unit))->setName($this->getName()); case self::UNIT_FTS: return $this->mul(new CustomUnit(3.28084, $unit))->setName($this->getName()); case self::UNIT_KMH: return $this->mul(new CustomUnit(3.6, $unit))->setName($this->getName()); } } /** * Returns the wind name, e.g «light breeze» */ public function getName(): string { return strtolower($this->name); } /** * Used on conversion */ protected function setName(string $name): self { $this->name = $name; return $this; } public function thresholdDiff(DiffInterface $e): bool { return $this->getName() != $e->getName(); } public function __toString(): string { return sprintf( '%s: %s (%01.1f %s)', basename(str_replace('\\', DIRECTORY_SEPARATOR, get_class($this))), $this->getName(), $this->getValue(), $this->getUnit() ); } }