name = (string)$xml['name']; } public function convertTo(string $unit): int { switch ($unit) { case self::UNIT_KNOTS: return $this->getValue() * 1.9438445; case self::UNIT_FTS: return $this->getValue() * 3.28084; case self::UNIT_KMH: return $this->getValue() * 3.6; } } public function getName(): string { return $this->name; } public function __toString(): string { return sprintf( '%s (%s)', parent::__toString(), $this->name ); } }