<?php
/**
 * Content Auditor Module.
 *
 * Scores every published post on Search Console traffic (from the GSC cache)
 * + on-page health into a Keep / Refresh / Merge / Delete worklist you can
 * filter, sort, and export. Recommend-only — it never edits or deletes.
 *
 * @package Platform\Helm\Modules\Content_Auditor
 */

declare( strict_types = 1 );

namespace Platform\Helm\Modules\Content_Auditor;

use Platform\Helm\Contracts\ModuleInterface;
use Platform\Helm\Core\Assets;
use Platform\Helm\Modules\GSC\GscStore;
use Platform\Helm\Modules\GSC\GscQueryStore;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class ContentAuditorModule implements ModuleInterface {

	private AuditStore $store;
	private AuditAjaxController $ajax;
	private AuditAdminPage $page;

	public function __construct( Assets $assets ) {
		$this->store = new AuditStore();
		$scanner     = new AuditScanner( $this->store, new GscStore() );
		$this->ajax  = new AuditAjaxController( $this->store, $scanner );
		$this->page  = new AuditAdminPage( $assets, $this->store, new GscQueryStore() );
	}

	public function id(): string {
		return 'content_auditor';
	}

	public function name(): string {
		return __( 'Content Auditor', 'platform-helm' );
	}

	public function description(): string {
		return __( 'Scores every post on Search Console traffic + on-page health into a Keep / Refresh / Merge / Delete worklist. Batched for WP Engine, recommend-only, exportable to CSV.', 'platform-helm' );
	}

	public function default_enabled(): bool {
		return false;
	}

	public function boot(): void {
		$this->store->maybe_create_table();
		$this->page->register_hooks();
		$this->ajax->register_hooks();
	}
}
