public function setBaseColor($baseColor) { if (preg_match('/^#[a-f0-9]{6}$/i', $baseColor)) { $this->baseColor = $baseColor; return $this; } throw new \InvalidArgumentException("{$baseColor} is not a valid hex color."); }