Completed
Push — add/extra-backup-api-calls ( 1cb03c )
by
unknown
37:50 queued 25:31
created

result()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3 View Code Duplication
class Jetpack_JSON_API_Get_Term_Backup_Endpoint extends Jetpack_JSON_API_Endpoint {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
4
	// /sites/%s/terms/%d/backup      -> $blog_id, $term_id
5
6
	protected $needed_capabilities = array();
7
	protected $term_id;
8
9
	function validate_input( $term_id ) {
10
		if ( empty( $term_id ) || ! is_numeric( $term_id ) ) {
11
			return new WP_Error( 'term_id_not_specified', __( 'You must specify a Term ID', 'jetpack' ) );
12
		}
13
14
		$this->term_id = intval( $term_id );
15
16
		return true;
17
	}
18
19
	protected function result() {
20
		$term = get_term( $this->term_id );
21
		if ( empty( $term ) ) {
22
			return new WP_Error( 'term_not_found', __( 'Term not found', 'jetpack' ) );
23
		}
24
25
		return array(
26
			'term' => (array)$term,
27
		);
28
	}
29
30
}
31
32