src/Token.php
public static function load(string $token, array $config): Token
    {
        $fields = ['id', 'h', 'e'];
        $params = [];

        parse_str(self::base64url_decode($token), $params);
        foreach ($fields as $f) {
            if (!array_key_exists($f, $params)) {
                throw new \UnexpectedValueException('"'. $f .'" should exists in token attributes.');
            }
        }

        $id = Identificator::load($params['id'], $config['idFields']);
        $token = new Token($id, $config);
        $token->setHash($params['h']);
        $token->setExpiration($params['e']);

        return $token;
    }
public static function load(string $token, array $config): Token
    {
        $fields = ['id', 'h', 'e'];
        $params = [];

        parse_str(self::base64url_decode($token), $params);
        foreach ($fields as $f) {
            if (!array_key_exists($f, $params)) {
                throw new \UnexpectedValueException('"'. $f .'" should exists in token attributes.');
            }
        }

        $id = Identificator::load($params['id'], $config['idFields']);
        $token = new Token($id, $config);
        $token->setHash($params['h']);
        $token->setExpiration($params['e']);

        return $token;
    }
public static function load ( string $ token , array $ config ) : Token { $ fields = [ 'id' , 'h' , 'e' ] ; $ params = [ ] ; parse_str ( self :: base64url_decode ( $ token ) , $ params ) ; foreach ( $ fields as $ f ) { if ( ! array_key_exists ( $ f , $ params ) ) { throw new \ UnexpectedValueException ( '"' . $ f . '" should exists in token attributes.' ) ; } } $ id = Identificator :: load ( $ params [ 'id' ] , $ config [ 'idFields' ] ) ; $ token = new Token ( $ id , $ config ) ; $ token -> setHash ( $ params [ 'h' ] ) ; $ token -> setExpiration ( $ params [ 'e' ] ) ; return $ token ; }
Create new token from string representation
@param string $token raw base64 encoded token
@param array $config configuration options like in constructor
return Token
Create new token from string representation