WordPress at a glance
function is not described

WP_REST_Comments_Controller::get_comment() protected WP 4.7.2

Get the comment, if the ID is valid.

{} It's a method of the class: WP_REST_Comments_Controller{}

No Hooks.

Return

WP_Comment/WP_Error. Comment object if ID is valid, WP_Error otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_comment( $id );
$id(int) (required)
Supplied ID.

Changelog

Since 4.7.2 Introduced.

Code of WP_REST_Comments_Controller::get_comment() WP 5.5.1

<?php
protected function get_comment( $id ) {
	$error = new WP_Error(
		'rest_comment_invalid_id',
		__( 'Invalid comment ID.' ),
		array( 'status' => 404 )
	);

	if ( (int) $id <= 0 ) {
		return $error;
	}

	$id      = (int) $id;
	$comment = get_comment( $id );
	if ( empty( $comment ) ) {
		return $error;
	}

	if ( ! empty( $comment->comment_post_ID ) ) {
		$post = get_post( (int) $comment->comment_post_ID );

		if ( empty( $post ) ) {
			return new WP_Error(
				'rest_post_invalid_id',
				__( 'Invalid post ID.' ),
				array( 'status' => 404 )
			);
		}
	}

	return $comment;
}