<?php

namespace App\Support;

class RichTextSanitizer
{
    private const ALLOWED_TAGS = '<p><br><strong><b><em><i><u><s><ul><ol><li><a><h1><h2><h3><h4><blockquote><span>';

    public static function clean(?string $html): ?string
    {
        if ($html === null) {
            return null;
        }

        $clean = trim(strip_tags($html, self::ALLOWED_TAGS));

        if ($clean === '' || trim(strip_tags($clean)) === '') {
            return null;
        }

        return $clean;
    }
}
