protected static function createNew(
        int $ttl,
        TokenOwnerInterface $owner = null,
        Client $client = null,
        array $scopes = null
    ): self {
        if (is_array($scopes)) {
            $scopes = array_map(function ($scope) {
                return (string) $scope;
            }, $scopes);
        }

        $token = new static();

        $token->token = bin2hex(random_bytes(20));
        $token->owner = $owner;
        $token->client = $client;
        $token->scopes = $scopes ?? [];
        $token->expiresAt = $ttl ? (new DateTime('@' . time(), new DateTimeZone('UTC')))->modify("+$ttl seconds") : null;

        return $token;
    }
protected static function createNew(
        int $ttl,
        TokenOwnerInterface $owner = null,
        Client $client = null,
        array $scopes = null
    ): self {
        if (is_array($scopes)) {
            $scopes = array_map(function ($scope) {
                return (string) $scope;
            }, $scopes);
        }

        $token = new static();

        $token->token = bin2hex(random_bytes(20));
        $token->owner = $owner;
        $token->client = $client;
        $token->scopes = $scopes ?? [];
        $token->expiresAt = $ttl ? (new DateTime('@' . time(), new DateTimeZone('UTC')))->modify("+$ttl seconds") : null;

        return $token;
    }
protected static function createNew ( int $ ttl , TokenOwnerInterface $ owner = null , Client $ client = null , array $ scopes = null ) : self { if ( is_array ( $ scopes ) ) { $ scopes = array_map ( function ( $ scope ) { return ( string ) $ scope ; } , $ scopes ) ; } $ token = new static ( ) ; $ token -> token = bin2hex ( random_bytes ( 20 ) ) ; $ token -> owner = $ owner ; $ token -> client = $ client ; $ token -> scopes = $ scopes ?? [ ] ; $ token -> expiresAt = $ ttl ? ( new DateTime ( '@' . time ( ) , new DateTimeZone ( 'UTC' ) ) ) -> modify ( "+$ttl seconds" ) : null ; return $ token ; }
Create a new AbstractToken

@param int                   $ttl
@param TokenOwnerInterface   $owner
@param Client                $client
@param string[]|Scope[]|null $scopes
@return AbstractToken
Create a new AbstractToken