Carbon_Breadcrumb_Item_Post   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 8 2
A setup_title() 0 5 1
A setup_link() 0 4 1
1
<?php
2
/**
3
 * Post breadcrumb item
4
 *
5
 * @package carbon-breadcrumbs
6
 */
7
8
/**
9
 * Breadcrumb item class for posts.
10
 *
11
 * Used for breadcrumb items that represent a post of any post type.
12
 */
13
class Carbon_Breadcrumb_Item_Post extends Carbon_Breadcrumb_Item_DB_Object {
14
15
	/**
16
	 * Configure the title and link URL by using the specified post ID.
17
	 *
18
	 * @access public
19
	 * @throws Carbon_Breadcrumb_Exception When post ID isn't specified.
20
	 */
21
	public function setup() {
22
		// In order to continue, post ID must be specified.
23
		if ( ! $this->get_id() ) {
24
			throw new Carbon_Breadcrumb_Exception( 'The post breadcrumb items must have post ID specified.' );
25
		}
26
27
		parent::setup();
28
	}
29
30
	/**
31
	 * Setup the title of this item.
32
	 *
33
	 * @access public
34
	 */
35
	public function setup_title() {
36
		$title = get_post_field( 'post_title', $this->get_id() );
37
		$title = apply_filters( 'the_title', $title, $this->get_id() );
38
		$this->set_title( $title );
39
	}
40
41
	/**
42
	 * Setup the link of this item.
43
	 *
44
	 * @access public
45
	 */
46
	public function setup_link() {
47
		$link = get_permalink( $this->get_id() );
48
		$this->set_link( $link );
49
	}
50
51
}
52