<?php

namespace ProudNerds\Admin;

use ProudNerds\Trait\Initializable;

/**
 * Creates help tabs.
 */
class HelpTabs
{
    use Initializable;

    private function __construct()
    {
        add_action('admin_head', [$this, 'createTabs']);
    }

    /**
     * Creates the help tabs.
     *
     * @return void
     */
    public function createTabs(): void
    {
        // $example = HelpTab::create()
        //     ->setTitle('Example title')
        //     ->setContent('Example content')
        //     ->setScreenId('edit-post')
        //     ->setPriority(10); // NOSONAR

        // $this->registerTab($example); // NOSONAR
    }

    /**
     * Registers a help tab.
     *
     * @param HelpTab $tab The tab to create.
     *
     * @return void
     */
    private function registerTab(HelpTab $tab): void // NOSONAR
    {
        // Dump this variable to see the current screen ID
        $screen = get_current_screen();

        if ($tab->getScreenId() !== '' && $screen->id !== $tab->getScreenId()) {
            return;
        }

        $screen->add_help_tab(
            [
                'id' => $tab->getId(),
                'title' => $tab->getTitle(),
                'content' => $tab->getContent(),
                'priority' => $tab->getPriority(),
            ]
        );
    }
}
