<?php
declare(strict_types=1);

namespace App\Framework\View\Processors;

use App\Framework\View\RenderContext;
use App\Framework\View\StringProcessor;

final class SingleLineHtmlProcessor implements StringProcessor
{
    public function process(string $html, RenderContext $context): string
    {
        // Entfernt Zeilenumbrüche und doppelte Whitespaces, alles in eine Zeile
        $html = preg_replace('/>(\s|\n|\r)+</', '><', $html);
        $html = preg_replace('/\s+/', ' ', $html);
        return trim($html);
    }
}
