<?php
declare(strict_types=1);

namespace App\Core\Events;

final class MemberActivated extends Event
{
    public function __construct(
        public readonly int $memberId,
        public readonly ?string $membershipNumber,
    ) {}

    public static function eventName(): string
    {
        return 'member.activated';
    }

    public function toArray(): array
    {
        return [
            'member_id' => $this->memberId,
            'membership_number' => $this->membershipNumber,
        ];
    }

    public static function from(array $data): static
    {
        return new self(
            memberId: (int) ($data['member_id'] ?? 0),
            membershipNumber: $data['membership_number'] ?? null,
        );
    }
}
