Completed
Push — master ( 2b661c...5d79c3 )
by Marin
02:11
created

Carbon_Breadcrumb_Item_Post   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10

3 Methods

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