Completed
Push — milestone/2.0 ( 5944fd...9cc217 )
by
unknown
02:37
created

WP_Toolset   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 44
rs 10
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_post_title() 0 3 1
A get_term_title() 0 4 1
A get_user_title() 0 3 1
A get_comment_title() 0 3 1
1
<?php
2
3
namespace Carbon_Fields\Toolset;
4
5
/**
6
 * Provides common tools when dealing with WordPress data such as posts, terms etc.
7
 */
8
class WP_Toolset {
9
10
	/**
11
	 * Get post title
12
	 *
13
	 * @param int $id
14
	 * @return string $title The title of the item.
15
	 */
16
	public function get_post_title( $id ) {
17
		return get_the_title( $id );
18
	}
19
20
	/**
21
	 * Get term title
22
	 *
23
	 * @param int $id
24
	 * @param string $subtype
25
	 * @return string $title The title of the item.
26
	 */
27
	public function get_term_title( $id, $subtype = '' ) {
28
		$term = get_term_by( 'id', $id, $subtype );
29
		return $term->name;
30
	}
31
32
	/**
33
	 * Get user title
34
	 *
35
	 * @param int $id
36
	 * @return string $title The title of the item.
37
	 */
38
	public function get_user_title( $id ) {
39
		return get_the_author_meta( 'user_login', $id );
40
	}
41
42
	/**
43
	 * Get comment title
44
	 *
45
	 * @param int $id
46
	 * @return string $title The title of the item.
47
	 */
48
	public function get_comment_title( $id ) {
49
		return get_comment_text( $id );
50
	}
51
}
52