<?php

namespace WPSN\Modules\AI;

defined('ABSPATH') || exit;

final class Redactor
{
    public static function redactPersonalData(string $text): string
    {
        // Emails.
        $text = preg_replace('/[A-Z0-9._%+\-]+@[A-Z0-9.\-]+\.[A-Z]{2,}/i', '[email]', $text) ?? $text;

        // Phone numbers (best-effort, international/local). Matches 8+ digits with common separators.
        $text = preg_replace('/\+?\d[\d\s().\-]{7,}\d/', '[phone]', $text) ?? $text;

        return $text;
    }
}
