public function createToken($payload, $secret = null, $algo = null)
{
$algo = $algo ?: $this->algorithm();
$secret = $secret ?: $this->secret();
if ($payload instanceof JwtPayloadInterface) {
$payload = $payload->getPayload();
}
$newToken = $this->jwt->createToken($payload, $secret, $algo);
$token = clone $this;
$token->setToken($newToken);
return $token;
}
public function it_encodes_to_json_as_a_string_representation_of_the_token(JwtDriverInterface $jwt) { $driver = new FirebaseDriver(); $jwt = new JwtToken($driver); $token = $jwt->createToken(['exp' => time() + 100], 'secret'); $serialized = json_encode(['token' => $token]); $decoded = json_decode($serialized); if (!is_string($decoded->token) || strlen($decoded->token) < 1) { throw new FailureException('Token was not json encoded.'); } }