/**
  * @param string $className
  *
  * @return TokenInterface
  */
 public function create($className)
 {
     /** @var TokenInterface $tokenInstance */
     $tokenInstance = new $className();
     if (!$tokenInstance instanceof TokenInterface) {
         throw new \RuntimeException("Class {$className} does not implement the correct interface");
     }
     // Set expiry time
     $expiresAt = null;
     if ($this->lifetime !== null) {
         $expiresAt = (new \DateTime())->modify("+{$this->lifetime} seconds");
     }
     $tokenInstance->setExpiresAt($expiresAt);
     // Generate token string
     $token = $this->random->generateString($this->length);
     $tokenInstance->setToken($token);
     return $tokenInstance;
 }
 /**
  * Returns a new authorization code instance
  *
  * @param string $className
  *
  * @return AuthorizationCodeInterface
  */
 public function create($className)
 {
     /** @var AuthorizationCodeInterface $authorizationCode */
     $authorizationCode = new $className();
     if (!$authorizationCode instanceof AuthorizationCodeInterface) {
         throw new \RuntimeException("Class {$className} does not implement the correct interface");
     }
     // Set expiry time
     $expiresAt = null;
     if ($this->lifetime !== null) {
         $expiresAt = (new \DateTime())->modify("+{$this->lifetime} seconds");
     }
     $authorizationCode->setExpiresAt($expiresAt);
     // Generate token string
     $code = $this->random->generateString($this->length);
     $authorizationCode->setCode($code);
     return $authorizationCode;
 }
 protected function generateClientSecret()
 {
     return $this->random->generateString($this->secretLength);
 }