public function setTheme(?string $key = null, bool $overrideKey = false) : Theme
    {
        if ($this->useTheme !== null && ($key === null || $this->useTheme === $key)) {
            return $this->useTheme;
        }

        if ($overrideKey) {
            return $this->useTheme = $this->getTheme($key);
        }

        if ($this->themes->hasOverride()) {
            return $this->useTheme = $this->themes->getOverride();
        }

        if ($this->hasUserOverride()) {
            return $this->useTheme = $this->themes->setOverride($this->getUserOverride());
        }

        return $this->useTheme = $this->getTheme($key);
    }