<?php

namespace App\Domain\Import\Stages;

use App\Domain\Import\PdfSplitter;

class SplitPdf
{
    public function __construct(private readonly PdfSplitter $splitter)
    {
    }

    public function handle(array $payload, \Closure $next): array
    {
        $payload['blocks'] = $this->splitter->split((string) ($payload['path'] ?? ''));
        $payload['is_valid'] = true;

        return $next($payload);
    }
}
