<?php

namespace QUI\WebsiteLocker;

use QUI\Interfaces\Projects\Site;

use function is_string;
use function trim;

final class Robots
{
    public const DEFAULT_DIRECTIVES = 'noindex';

    public static function getDirectives(Site $Site): string
    {
        $directives = $Site->getAttribute('meta.robots');

        if (!is_string($directives)) {
            return self::DEFAULT_DIRECTIVES;
        }

        $directives = trim($directives);

        if ($directives === '') {
            return self::DEFAULT_DIRECTIVES;
        }

        return $directives;
    }
}
