<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Lifecycle;

use PpPhp\Core\Platform\Event\Event;
use PpPhp\Core\Platform\Event\Lifecycle\Contracts\LifecycleEventInterface;

class LifecycleEvent extends Event implements LifecycleEventInterface
{
    public function __construct(
        string $name,
        private readonly string $category,
        private readonly string $phase,
        private readonly string $subject,
        array $payload = [],
        array $metadata = []
    ) {
        parent::__construct($name, $payload, $metadata);
    }

    public function category(): string { return $this->category; }
    public function phase(): string { return $this->phase; }
    public function subject(): string { return $this->subject; }

    public function toArray(): array
    {
        return parent::toArray() + [
            'category' => $this->category,
            'phase' => $this->phase,
            'subject' => $this->subject,
        ];
    }
}
