<?php

namespace FleekDash\Traits;

trait BaseModuleOptionsTrait
{
    abstract protected function getName(): string;

    /**
     * get_option namespaced to this module.
     */
    protected function get_option(string $key, mixed $default = null): mixed // NOSONAR php:S100 - backward-compatible internal API
    {
        return \get_option("fleekdash_module_{$this->getName()}_{$key}", $default);
    }

    /**
     * update_option namespaced to this module.
     */
    protected function update_option(string $key, mixed $value): bool // NOSONAR php:S100 - backward-compatible internal API
    {
        return \update_option("fleekdash_module_{$this->getName()}_{$key}", $value);
    }

    /**
     * delete_option namespaced to this module.
     */
    protected function delete_option(string $key): bool // NOSONAR php:S100 - backward-compatible internal API
    {
        return \delete_option("fleekdash_module_{$this->getName()}_{$key}");
    }
}
