<?php

declare(strict_types=1);

namespace App\Framework\Exception\SecurityEvent;

use App\Framework\Exception\SecurityLogLevel;

/**
 * Login-Erfolg Event
 */
final readonly class AuthenticationLoginSuccessEvent implements SecurityEventInterface
{
    public function __construct(
        public string $userId
    ) {}

    public function getEventIdentifier(): string
    {
        return "authn_login_success:{$this->userId}";
    }

    public function getDescription(): string
    {
        return "User {$this->userId} login successfully";
    }

    public function getLogLevel(): SecurityLogLevel
    {
        return SecurityLogLevel::INFO;
    }

    public function getCategory(): string
    {
        return 'authentication';
    }

    public function requiresAlert(): bool
    {
        return false;
    }

    public function toArray(): array
    {
        return [
            'userId' => $this->userId,
            'event_identifier' => $this->getEventIdentifier(),
            'category' => $this->getCategory(),
            'log_level' => $this->getLogLevel()->value,
            'requires_alert' => $this->requiresAlert()
        ];
    }
}
