original_string: public static function get_conversation_counts(int $userid) {
          global $CFG, $USER;
  
          // All the business logic checks that really shouldn't be in here.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          if (empty($userid)) {
              $userid = $USER->id;
          }
  
          $params = ['userid' => $userid];
          $params = self::validate_parameters(self::get_conversation_counts_parameters(), $params);
  
          $systemcontext = context_system::instance();
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          return \core_message\api::get_conversation_counts($params['userid']);
      }
code: public static function get_conversation_counts(int $userid) {
          global $CFG, $USER;
  
          // All the business logic checks that really shouldn't be in here.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          if (empty($userid)) {
              $userid = $USER->id;
          }
  
          $params = ['userid' => $userid];
          $params = self::validate_parameters(self::get_conversation_counts_parameters(), $params);
  
          $systemcontext = context_system::instance();
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          return \core_message\api::get_conversation_counts($params['userid']);
      }
code_tokens: public static function get_conversation_counts ( int $ userid ) { global $ CFG , $ USER ; // All the business logic checks that really shouldn't be in here. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } if ( empty ( $ userid ) ) { $ userid = $ USER -> id ; } $ params = [ 'userid' => $ userid ] ; $ params = self :: validate_parameters ( self :: get_conversation_counts_parameters ( ) , $ params ) ; $ systemcontext = context_system :: instance ( ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } return \ core_message \ api :: get_conversation_counts ( $ params [ 'userid' ] ) ; }
docstring: Returns an array of conversation counts for the various types of conversations, including favourites.
  
  Return format:
  [
  'favourites' => 0,
  'types' => [
  \core_message\api::MESSAGE_CONVERSATION_TYPE_INDIVIDUAL => 0,
  \core_message\api::MESSAGE_CONVERSATION_TYPE_GROUP => 0
  ]
  ]
  
  @param int $userid the id of the user whose counts we are fetching.
  @return array the array of conversation counts, indexed by type.
  @throws moodle_exception if the current user cannot perform this action.
docstring_tokens: Returns an array of conversation counts for the various types of conversations including favourites .