<?php
namespace boru\boruai\Openai\Stream;

/**
 * Catchall DTO for unknown/unmapped stream event types.
 *
 * This prevents StreamEvent::fromEvent() from throwing when OpenAI introduces
 * new event types that we have not yet added typed DTOs for.
 */
class UnknownEvent extends StreamEvent {
    /**
     * The fully-qualified class name StreamEvent::fromEvent() attempted to
     * instantiate.
     *
     * @var string
     */
    private $expectedClassName;

    public function expectedClassName($expectedClassName=null) {
        if ($expectedClassName !== null) {
            $this->expectedClassName = $expectedClassName;
        }
        return $this->expectedClassName;
    }

    public function toArray() {
        return [
            'type' => $this->type(),
            'expectedClassName' => $this->expectedClassName(),
            'data' => $this->data(),
        ];
    }
}
