/**
  * getToken.
  *
  * @return JwtToken
  */
 public function getJwtToken()
 {
     if ($this->token && $this->token->isValid()) {
         return $this->token;
     }
     $url = $this->options['token_url'];
     $requestOptions = array_merge($this->getDefaultHeaders(), $this->auth->getRequestOptions());
     $response = $this->client->request('POST', $url, $requestOptions);
     $body = json_decode($response->getBody(), true);
     $expiresIn = isset($body[$this->options['expire_key']]) ? $body[$this->options['expire_key']] : null;
     if ($expiresIn) {
         $expiration = new \DateTime('now + ' . $expiresIn . ' seconds');
     } else {
         $expiration = null;
     }
     $this->token = new JwtToken($body[$this->options['token_key']], $expiration);
     return $this->token;
 }
 public function testTokenShouldBeValidIfExpirationIsInTheFuture()
 {
     $token = new JwtToken('foo', new \DateTime('now + 5 minutes'));
     $this->assertTrue($token->isValid());
 }