Simple tokens

1.1.0 2023-01-03 13:25 UTC

This package is auto-updated.

Last update: 2024-04-30 00:39:23 UTC


README

68747470733a2f2f7374617469632e6765726d616e69612d6b672e636f6d2f6c6f676f732f67612d6c6f676f2d323031362d7765622e7376677a

Germania KG · Token

Simple tokens

Packagist PHP version Tests

Installation

$ composer install germania-kg/token

Interface TokenInterface

interface TokenInterface
{
    // Alias for "getContent"
    public function __toString();

    // Returns the token "text".
  	public function getContent() : string;

    // Returns the lifetime in seconds.
    public function getLifeTime() : int;
}

Class AuthToken

<?php
use Germania\Token\Token;

// Pass token string and TTL
$auth_token = new Token( "somerandomstring", 3600);

echo $auth_token;                // "somerandomstring"
echo $auth_token->__toString();  // "somerandomstring"  
echo $auth_token->getContent();  // "somerandomstring"  
echo $auth_token->getLifeTime(); // 3600

Testing

$ composer phpunit