/**
  * Get a user entity.
  *
  * @param string $identifier
  *
  * @return \League\OAuth2\Server\Entities\UserEntityInterface
  */
 public function getUserEntityByIdentifier($identifier)
 {
     $userVerifier = app()->make(Oauth2Server::class)->getOptions()['user_verifier'];
     $user = (new $userVerifier())->getUserByIdentifier($identifier);
     if (is_null($identifier)) {
         return;
     }
     $userEntity = new UserEntity();
     $userEntity->setIdentifier((string) $user->id);
     return $userEntity;
 }
 /**
  * get getAccessTokensForUser.
  *
  * @param $userId
  *
  * @return array|null
  */
 public function getAccessTokensForUser($userId)
 {
     $accessTokenRepository = new AccessTokenRepository();
     // instance of AccessTokenRepositoryInterface
     $user = new UserEntity();
     // instance of AccessTokenRepositoryInterface
     $user->setIdentifier($userId);
     return $accessTokenRepository->findAccessTokensByUser($user);
 }