name = (string)$xml['name']; } /** * Convert the wind speed to a different unit * * @param string $unit The unit to convert to, eg UNIT_FTS */ public function convertTo(string $unit): self { 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 $this->name; } protected function setName(string $name): self { $this->name = $name; return $this; } /** * {@inheritDoc} */ public function diff(DiffInterface $e): int { if (parent::diff($e)) return ($this->getName() != $e->getName()) ? 1 : 0; return 0; } public function __toString(): string { return sprintf( '%s (%s)', parent::__toString(), $this->name ); } }