Inheritance: implements JsonSerializabl\JsonSerializable
 /**
  * Create a new JWT token object from the token in the request
  *
  * @param Request|null $request
  *
  * @return JwtToken
  *
  * @throws NoTokenException
  */
 public function jwtToken($request = null)
 {
     $token = $this->getToken($request);
     if (!$token) {
         throw new NoTokenException('JWT token is required.');
     }
     $driver = $this->makeDriver();
     $jwt = new JwtToken($driver);
     $jwt->setToken($token);
     return $jwt;
 }
 /**
  * Validate JWT token before passing on to the next middleware
  *
  * @param \Illuminate\Http\Request $request
  * @param Closure                  $next
  */
 public function handle($request, Closure $next)
 {
     $token = $this->getTokenFromRequest($request);
     $this->jwt->setToken($token)->validateOrFail();
     return $next($request);
 }
 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.');
     }
 }