<?php

namespace ArvaSeo\Actions;

use ArvaSeo\Repositories\CrawlResultsRepository;
use ArvaSeo\Services\Licensing;
class ExportCrawl {
    private CrawlResultsRepository $repository;

    private Licensing $licensing;

    public function __construct( CrawlResultsRepository $repository, Licensing $licensing ) {
        $this->repository = $repository;
        $this->licensing = $licensing;
    }

    public function handle() : void {
        if ( !current_user_can( 'manage_options' ) ) {
            wp_die( esc_html__( 'You are not allowed to export crawl data.', 'bulk-meta-editor' ) );
        }
        check_admin_referer( 'arva_seo_export_crawl', 'arva_seo_export_nonce' );
        if ( function_exists( 'arva_seo_fs' ) && arva_seo_fs()->is__premium_only() ) {
            $this->export__premium_only();
            return;
        }
        wp_die( esc_html( $this->licensing->get_crawl_upgrade_message() ) );
    }

}
