<?php
declare(strict_types=1);

namespace App\Core\Events;

final class FinePaid extends Event
{
    public function __construct(
        public readonly int $fineId,
        public readonly int $memberId,
        public readonly string $amount,
    ) {}

    public static function eventName(): string
    {
        return 'fine.paid';
    }

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

    public static function from(array $data): static
    {
        return new self(
            fineId: (int) ($data['fine_id'] ?? 0),
            memberId: (int) ($data['member_id'] ?? 0),
            amount: (string) ($data['amount'] ?? '0.00'),
        );
    }
}
