original_string: public static function clean_field($data, $field) {
          if (empty($data) || empty($field)) {
              return $data;
          }
  
          try {
              $type = core_user::get_property_type($field);
  
              if (isset(self::$propertiescache[$field]['choices'])) {
                  if (!array_key_exists($data, self::$propertiescache[$field]['choices'])) {
                      if (isset(self::$propertiescache[$field]['default'])) {
                          $data = self::$propertiescache[$field]['default'];
                      } else {
                          $data = '';
                      }
                  } else {
                      return $data;
                  }
              } else {
                  $data = clean_param($data, $type);
              }
          } catch (coding_exception $e) {
              debugging("The property '$field' could not be cleaned.", DEBUG_DEVELOPER);
          }
  
          return $data;
      }
code: public static function clean_field($data, $field) {
          if (empty($data) || empty($field)) {
              return $data;
          }
  
          try {
              $type = core_user::get_property_type($field);
  
              if (isset(self::$propertiescache[$field]['choices'])) {
                  if (!array_key_exists($data, self::$propertiescache[$field]['choices'])) {
                      if (isset(self::$propertiescache[$field]['default'])) {
                          $data = self::$propertiescache[$field]['default'];
                      } else {
                          $data = '';
                      }
                  } else {
                      return $data;
                  }
              } else {
                  $data = clean_param($data, $type);
              }
          } catch (coding_exception $e) {
              debugging("The property '$field' could not be cleaned.", DEBUG_DEVELOPER);
          }
  
          return $data;
      }
code_tokens: public static function clean_field ( $ data , $ field ) { if ( empty ( $ data ) || empty ( $ field ) ) { return $ data ; } try { $ type = core_user :: get_property_type ( $ field ) ; if ( isset ( self :: $ propertiescache [ $ field ] [ 'choices' ] ) ) { if ( ! array_key_exists ( $ data , self :: $ propertiescache [ $ field ] [ 'choices' ] ) ) { if ( isset ( self :: $ propertiescache [ $ field ] [ 'default' ] ) ) { $ data = self :: $ propertiescache [ $ field ] [ 'default' ] ; } else { $ data = '' ; } } else { return $ data ; } } else { $ data = clean_param ( $ data , $ type ) ; } } catch ( coding_exception $ e ) { debugging ( "The property '$field' could not be cleaned." , DEBUG_DEVELOPER ) ; } return $ data ; }
docstring: Clean a specific user field.
  
  @param string $data the user field data to be cleaned.
  @param string $field the user field name on the property definition cache.
  @return string the cleaned user data.
docstring_tokens: Clean a specific user field .