<?php
declare(strict_types=1);

namespace App\Seo;

final class ProfileIndexPolicy
{
    /** @param array<string,mixed> $user @param array<string,mixed> $summary */
    public static function isIndexable(array $user, array $summary): bool
    {
        $accountType = strtolower(trim((string) ($user['account_type'] ?? 'member')));
        if ($accountType !== 'member') return false;
        if (trim((string) ($user['username'] ?? '')) === '' || strtolower(trim((string) ($user['status'] ?? 'active'))) !== 'active') return false;
        if (trim((string) ($user['bio'] ?? '')) !== '') return true;
        foreach (['questions', 'answers', 'topics'] as $key) {
            if ((int) ($summary[$key] ?? 0) > 0) return true;
        }
        return false;
    }
}
