Newer
Older
gnexus-auth-client-php / src / Support / InMemoryTokenStore.php
@Eugene Sukhodolskiy Eugene Sukhodolskiy 12 hours ago 609 bytes Initial auth client package scaffold
<?php

declare(strict_types=1);

namespace GNexus\GAuth\Support;

use GNexus\GAuth\Contract\TokenStoreInterface;
use GNexus\GAuth\DTO\TokenSet;

final class InMemoryTokenStore implements TokenStoreInterface
{
    /**
     * @var array<string, TokenSet>
     */
    private array $items = [];

    public function put(string $key, TokenSet $tokenSet): void
    {
        $this->items[$key] = $tokenSet;
    }

    public function get(string $key): ?TokenSet
    {
        return $this->items[$key] ?? null;
    }

    public function forget(string $key): void
    {
        unset($this->items[$key]);
    }
}