<?php

declare(strict_types=1);

namespace BeycanPress\Tokenico\Pages;

use BeycanPress\Tokenico\PluginHero\Page;
use BeycanPress\Tokenico\PluginHero\Helpers;

class DebugLogs extends Page
{
    /**
     * @return void
     */
    public function __construct()
    {
        parent::__construct([
            'priority' => 11,
            'parent' => 'tokenico-settings',
            'pageName' => esc_html__('Debug logs', 'tokenico'),
        ]);
    }

    /**
     * @return void
     */
    public function page(): void
    {
        if ($_POST['delete'] ?? 0) {
            Helpers::deleteLogFile();
        }

        Helpers::viewEcho('pages/debug-logs', [
            'logs' => Helpers::getLogFile(),
            'pageUrl' => Helpers::getCurrentUrl()
        ]);
    }
}
