/**
  * Make sure token is unique or throw an exception.
  *
  * @param $token
  *
  * @return string
  *
  * @throws Exception
  */
 protected function makeUniqueToken($token)
 {
     $tries = 0;
     // Loop while token is not unique
     while ($this->medicalCenter->withTokenExists($token)) {
         $token = $this->makeRandomToken();
         $tries++;
         if ($tries > 30) {
             throw new Exception('Cannot make token unique', 1);
         }
     }
     return $token;
 }