<?php
declare(strict_types=1);

namespace Help4BuilderSuite\Support;

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

final class RobotsContract
{
    /** @return array<string, bool|string> */
    public static function effectiveDirectives(): array
    {
        // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This is WordPress core's canonical robots extension contract.
        $robots = apply_filters('wp_robots', []);
        return is_array($robots) ? $robots : ['noindex' => true, 'nofollow' => true];
    }

    public static function isIndexable(): bool
    {
        return empty(self::effectiveDirectives()['noindex']);
    }
}
