<?php

namespace WPSN\Modules\IndexationRisk;

use WPSN\Core\AbstractModule;

defined('ABSPATH') || exit;

/**
 * Indexation Risk Scanner.
 *
 * Detects orphan/thin/out-of-sitemap pages and assigns a simple risk score.
 */
final class IndexationRiskModule extends AbstractModule
{
    public function id(): string
    {
        return 'indexation_risk';
    }

    public function name(): string
    {
        return __('Indexation Risk', 'wp-seo-next');
    }

    public function description(): string
    {
        return __('Scan published content for indexation risks (orphans, thin content, sitemap exclusions).', 'wp-seo-next');
    }

    public function defaultEnabled(): bool
    {
        return true;
    }

    public function register(): void
    {
        add_action('init', [IndexationRiskInstaller::class, 'maybeInstall'], 1);

        $jobs = new IndexationRiskJobs(
            $this->container->get('settings'),
            $this->container->get('logger'),
            $this->container->get('queue')
        );

        add_filter('wpsn_queue_handle_' . IndexationRiskJobs::JOB_SCAN, [$jobs, 'handleScan'], 10, 3);

        if (is_admin()) {
            $admin = new Admin\IndexationRiskAdmin($this->container);
            $admin->register();
        }
    }
}
