original_string: public static function increment_idnumber($idnumber) {
          global $DB;
          while ($DB->record_exists('course', array('idnumber' => $idnumber))) {
              $matches = array();
              if (!preg_match('/(.*?)([0-9]+)$/', $idnumber, $matches)) {
                  $newidnumber = $idnumber . '_2';
              } else {
                  $newidnumber = $matches[1] . ((int) $matches[2] + 1);
              }
              $idnumber = $newidnumber;
          }
          return $idnumber;
      }
code: public static function increment_idnumber($idnumber) {
          global $DB;
          while ($DB->record_exists('course', array('idnumber' => $idnumber))) {
              $matches = array();
              if (!preg_match('/(.*?)([0-9]+)$/', $idnumber, $matches)) {
                  $newidnumber = $idnumber . '_2';
              } else {
                  $newidnumber = $matches[1] . ((int) $matches[2] + 1);
              }
              $idnumber = $newidnumber;
          }
          return $idnumber;
      }
code_tokens: public static function increment_idnumber ( $ idnumber ) { global $ DB ; while ( $ DB -> record_exists ( 'course' , array ( 'idnumber' => $ idnumber ) ) ) { $ matches = array ( ) ; if ( ! preg_match ( '/(.*?)([0-9]+)$/' , $ idnumber , $ matches ) ) { $ newidnumber = $ idnumber . '_2' ; } else { $ newidnumber = $ matches [ 1 ] . ( ( int ) $ matches [ 2 ] + 1 ) ; } $ idnumber = $ newidnumber ; } return $ idnumber ; }
docstring: Helper to increment an ID number.
  
  This first checks if the ID number is in use.
  
  @param string $idnumber ID number to increment.
  @return string new ID number.
docstring_tokens: Helper to increment an ID number .