public function add(ThemeSettings $settings, string $key = null) : ?Theme
    {
        if ($key !== null) {
            $settings->key = $key;
        }

        if ($this->has($settings->key)) {
            throw new KeyExistsException("Theme with key '{$settings->key}' already exists");
        }

        if ($settings->enabled) {
            $theme = new Theme($settings);

            if ($settings->default === true && $this->default === null) {
                $this->setDefault($theme);
            }

            if ($settings->override === true && $this->override === null) {
                $this->setOverride($theme);
            }

            $this->themes[$settings->key] = $theme;
        }

        return $theme ?? null;
    }
public function add(ThemeSettings $settings, string $key = null) : ?Theme
    {
        if ($key !== null) {
            $settings->key = $key;
        }

        if ($this->has($settings->key)) {
            throw new KeyExistsException("Theme with key '{$settings->key}' already exists");
        }

        if ($settings->enabled) {
            $theme = new Theme($settings);

            if ($settings->default === true && $this->default === null) {
                $this->setDefault($theme);
            }

            if ($settings->override === true && $this->override === null) {
                $this->setOverride($theme);
            }

            $this->themes[$settings->key] = $theme;
        }

        return $theme ?? null;
    }
public function add ( ThemeSettings $ settings , string $ key = null ) : ? Theme { if ( $ key !== null ) { $ settings -> key = $ key ; } if ( $ this -> has ( $ settings -> key ) ) { throw new KeyExistsException ( "Theme with key '{$settings->key}' already exists" ) ; } if ( $ settings -> enabled ) { $ theme = new Theme ( $ settings ) ; if ( $ settings -> default === true && $ this -> default === null ) { $ this -> setDefault ( $ theme ) ; } if ( $ settings -> override === true && $ this -> override === null ) { $ this -> setOverride ( $ theme ) ; } $ this -> themes [ $ settings -> key ] = $ theme ; } return $ theme ?? null ; }
Add a theme if enabled

@param \Laranix\Themer\ThemeSettings $settings
@param string|null                   $key
@return \Laranix\Themer\Theme|null
@throws \Laranix\Support\Exception\KeyExistsException
Add a theme if enabled