original_string: public static function getDbLock($lockName, $maxRetries = 30)
      {
          if (strlen($lockName) > 64) {
              throw new \Exception('DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.');
          }
  
          /*
           * the server (e.g., shared hosting) may have a low wait timeout
           * so instead of a single GET_LOCK() with a 30 second timeout,
           * we use a 1 second timeout and loop, to avoid losing our MySQL
           * connection
           */
          $sql = 'SELECT GET_LOCK(?, 1)';
  
          $db = self::get();
  
          while ($maxRetries > 0) {
              $result = $db->fetchOne($sql, array($lockName));
              if ($result == '1') {
                  return true;
              }
              $maxRetries--;
          }
  
          return false;
      }
code: public static function getDbLock($lockName, $maxRetries = 30)
      {
          if (strlen($lockName) > 64) {
              throw new \Exception('DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.');
          }
  
          /*
           * the server (e.g., shared hosting) may have a low wait timeout
           * so instead of a single GET_LOCK() with a 30 second timeout,
           * we use a 1 second timeout and loop, to avoid losing our MySQL
           * connection
           */
          $sql = 'SELECT GET_LOCK(?, 1)';
  
          $db = self::get();
  
          while ($maxRetries > 0) {
              $result = $db->fetchOne($sql, array($lockName));
              if ($result == '1') {
                  return true;
              }
              $maxRetries--;
          }
  
          return false;
      }
code_tokens: public static function getDbLock ( $ lockName , $ maxRetries = 30 ) { if ( strlen ( $ lockName ) > 64 ) { throw new \ Exception ( 'DB lock name has to be 64 characters or less for MySQL 5.7 compatibility.' ) ; } /*
           * the server (e.g., shared hosting) may have a low wait timeout
           * so instead of a single GET_LOCK() with a 30 second timeout,
           * we use a 1 second timeout and loop, to avoid losing our MySQL
           * connection
           */ $ sql = 'SELECT GET_LOCK(?, 1)' ; $ db = self :: get ( ) ; while ( $ maxRetries > 0 ) { $ result = $ db -> fetchOne ( $ sql , array ( $ lockName ) ) ; if ( $ result == '1' ) { return true ; } $ maxRetries -- ; } return false ; }
docstring: Attempts to get a named lock. This function uses a timeout of 1s, but will
  retry a set number of times.
  
  @param string $lockName The lock name.
  @param int $maxRetries The max number of times to retry.
  @return bool `true` if the lock was obtained, `false` if otherwise.
  @throws \Exception if Lock name is too long
docstring_tokens: Attempts to get a named lock . This function uses a timeout of 1s but will retry a set number of times .