Completed
Pull Request — develop (#1328)
by
unknown
03:09
created

Default_Term_Data   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get_data() 0 11 1
1
<?php
2
/**
3
 * @since 3.30.0
4
 * @author Naveen Muthusamy <[email protected]>
5
 * This class constructs the term data structure from the analysis service.
6
 */
7
8
namespace Wordlift\Vocabulary\Data\Term_Data;
9
10
class Default_Term_Data implements Term_Data {
11
12
	/**
13
	 * @var array An array of entities bound to the term.
14
	 */
15
	private $entities;
16
	/**
17
	 * @var \WP_Term
18
	 */
19
	private $term;
20
21
	public function __construct( $term, $entities ) {
22
		$this->term     = $term;
23
		$this->entities = $entities;
24
	}
25
26
	public function get_data() {
27
28
		return array(
29
			'tagId'          => $this->term->term_id,
30
			'tagName'        => $this->term->name,
31
			'tagDescription' => $this->term->description,
32
			'tagLink'        => get_edit_tag_link( $this->term->term_id, 'post_tag' ),
33
			'tagPostCount'   => $this->term->count,
34
			'entities'       => $this->entities,
35
		);
36
	}
37
}