<?php

namespace App\Services\Auth;

use Illuminate\Session\Store;

class SessionActivityService
{
    public function __construct(private Store $session)
    {
    }

    public function hasLastActivity(): bool
    {
        return $this->session->has('last_activity');
    }

    public function getLastActivity(): ?int
    {
        $value = $this->session->get('last_activity');
        return $value !== null ? (int) $value : null;
    }

    public function setLastActivity(int $timestamp): void
    {
        $this->session->put('last_activity', $timestamp);
    }

    public function clearLastActivity(): void
    {
        $this->session->forget('last_activity');
    }

    public function invalidate(): void
    {
        $this->session->invalidate();
        $this->session->regenerateToken();
    }
}
