Completed
Push — add/improve-search-upgrade-mes... ( 2d1617 )
by
unknown
06:46
created

WPCOM_REST_API_V2_Endpoint_Hello   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A register_routes() 0 8 1
A get_data() 0 3 1
1
<?php
2
3
class WPCOM_REST_API_V2_Endpoint_Hello {
4
	public function __construct() {
5
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
6
	}
7
8
	public function register_routes() {
9
		register_rest_route( 'wpcom/v2', '/hello', array(
10
			array(
11
				'methods'  => WP_REST_Server::READABLE,
12
				'callback' => array( $this, 'get_data' ),
13
			),
14
		) );
15
	}
16
17
	public function get_data( $request ) {
18
		return array( 'hello' => 'world' );
19
	}
20
}
21
22
wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Hello' );
23