uri = $uri; $this->title = $title; $this->setColour($colour); } /* * Getters and Setters */ public function setColour(string $colour = null) { if ($colour === null) { $this->colour = null; return; } if (!preg_match("/^#([0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/", $colour)) { trigger_error("Colour invalid", E_USER_WARNING); return; } $this->colour = $colour; } public function getColour() { return $this->colour ?? "No colour specified"; } /* * Meta */ public function __toString() { $style = $this->colour ? "style=\"color:$this->colour;\"" : ""; return <<$this->title END; } }