original_string: public static function remove_contact(int $userid, int $contactid) {
          global $DB;
  
          if ($contact = self::get_contact($userid, $contactid)) {
              $DB->delete_records('message_contacts', ['id' => $contact->id]);
  
              $event = \core\event\message_contact_removed::create(array(
                  'objectid' => $contact->id,
                  'userid' => $userid,
                  'relateduserid' => $contactid,
                  'context' => \context_user::instance($userid)
              ));
              $event->add_record_snapshot('message_contacts', $contact);
              $event->trigger();
          }
      }
code: public static function remove_contact(int $userid, int $contactid) {
          global $DB;
  
          if ($contact = self::get_contact($userid, $contactid)) {
              $DB->delete_records('message_contacts', ['id' => $contact->id]);
  
              $event = \core\event\message_contact_removed::create(array(
                  'objectid' => $contact->id,
                  'userid' => $userid,
                  'relateduserid' => $contactid,
                  'context' => \context_user::instance($userid)
              ));
              $event->add_record_snapshot('message_contacts', $contact);
              $event->trigger();
          }
      }
code_tokens: public static function remove_contact ( int $ userid , int $ contactid ) { global $ DB ; if ( $ contact = self :: get_contact ( $ userid , $ contactid ) ) { $ DB -> delete_records ( 'message_contacts' , [ 'id' => $ contact -> id ] ) ; $ event = \ core \ event \ message_contact_removed :: create ( array ( 'objectid' => $ contact -> id , 'userid' => $ userid , 'relateduserid' => $ contactid , 'context' => \ context_user :: instance ( $ userid ) ) ) ; $ event -> add_record_snapshot ( 'message_contacts' , $ contact ) ; $ event -> trigger ( ) ; } }
docstring: Handles removing a contact.
  
  @param int $userid The id of the user who is removing a user as a contact
  @param int $contactid The id of the user to be removed as a contact
docstring_tokens: Handles removing a contact .