Emarref\Jwt\Jwt::serialize PHP Метод

serialize() публичный Метод

public serialize ( Token $token, Emarref\Jwt\Encryption\EncryptionInterface $encryption ) : string
$token Token
$encryption Emarref\Jwt\Encryption\EncryptionInterface
Результат string
    public function serialize(Token $token, Encryption\EncryptionInterface $encryption)
    {
        $this->sign($token, $encryption);
        $serialization = new Serialization\Compact($this->encoder, new HeaderParameter\Factory(), new Claim\Factory());
        return $serialization->serialize($token);
    }

Usage Example

Пример #1
0
 protected static function authorization()
 {
     $token = new Emarref\Jwt\Token();
     $parameter = new Emarref\Jwt\HeaderParameter\Custom('typ', 'JWT');
     $token->addHeader($parameter, true);
     $token->addClaim(new Emarref\Jwt\Claim\Expiration(new \DateTime(self::$duration)));
     $jwt = new Emarref\Jwt\Jwt();
     $algorithm = new Emarref\Jwt\Algorithm\Hs256(self::$appSecret);
     $encryption = Emarref\Jwt\Encryption\Factory::create($algorithm);
     $serializedToken = $jwt->serialize($token, $encryption);
     return $serializedToken;
 }
All Usage Examples Of Emarref\Jwt\Jwt::serialize