<?php

namespace App\Framework\View\Processing;

use App\Framework\View\ProcessorResolver;
use App\Framework\View\RenderContext;

final readonly class StringProcessingPipeline
{
    public function __construct(
        private array             $processors,
        private ProcessorResolver $resolver,
    )
    {
    }

    public function process(string $html, RenderContext $context): string
    {
        foreach ($this->processors as $processorClass) {
            $processor = $this->resolver->resolve($processorClass);
            $html = $processor->process($html, $context);
        }
        return $html;
    }
}
