<?php

namespace App\Framework\View;

/**
 * Processor Instruction Value Object
 *
 * Repräsentiert eine einzelne Processor-Anweisung im Template
 */
final readonly class ProcessorInstruction
{
    public function __construct(
        public string $processorType,
        public string $pattern,
        public array  $metadata
    ) {}

    public function toArray(): array
    {
        return [
            'processor_type' => $this->processorType,
            'pattern' => $this->pattern,
            'metadata' => $this->metadata,
        ];
    }

    public static function fromArray(array $data): self
    {
        return new self(
            processorType: $data['processor_type'],
            pattern      : $data['pattern'],
            metadata     : $data['metadata']
        );
    }
}
