<?php

namespace App\EventHooks\System;

use App\EventHooks\HookEvent;

/**
 * Fire noktası: SavedPaymentMethodObserver::created/updated (CCUpdate hook).
 * Context: userid/user_id/client_id, saved_payment_method_id, gateway,
 * card_brand, last_four, expiry_month/year, action. Token/PAN context'te YOK.
 */
class PaymentMethodUpdated extends HookEvent
{
    public const HOOK = 'CCUpdate';

    public function clientId(): ?int
    {
        $id = $this->get('client_id') ?? $this->get('userid') ?? $this->get('user_id');

        return $id ? (int) $id : null;
    }

    public function gateway(): ?string
    {
        return $this->get('gateway');
    }

    public function lastFour(): ?string
    {
        $v = $this->get('last_four');

        return $v !== null ? (string) $v : null;
    }
}
