Carbon_Breadcrumb_Locator_Hierarchical   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_item_hierarchy() 0 16 2
get_parent_id() 0 1 ?
1
<?php
2
/**
3
 * Hierarchical breadcrumb item locator
4
 *
5
 * @package carbon-breadcrumbs
6
 */
7
8
/**
9
 * Abstract breadcrumb item locator class for hierarchical types.
10
 *
11
 * Used as a base for taxonomy, post type and other hierarchical locators.
12
 */
13
abstract class Carbon_Breadcrumb_Locator_Hierarchical extends Carbon_Breadcrumb_Locator {
14
15
	/**
16
	 * Retrieve the items, found by this locator.
17
	 *
18
	 * @access public
19
	 *
20
	 * @param int $id The object ID, used to go up the item tree.
21
	 * @param int $priority The priority of the located items.
22
	 * @return array $items The items hierarchy.
23
	 */
24
	public function get_item_hierarchy( $id, $priority ) {
25
		$items = array();
26
27
		do {
28
			$item = Carbon_Breadcrumb_Item::factory( $this->get_type(), $priority );
29
			$item->set_id( $id );
30
			$item->set_subtype( $this->get_subtype() );
31
			$item->setup();
32
33
			$items[] = $item;
34
35
			$id = $this->get_parent_id( $id );
36
		} while ( $id );
37
38
		return array_reverse( $items );
39
	}
40
41
	/**
42
	 * Get the parent ID of a specific item ID
43
	 *
44
	 * @access public
45
	 *
46
	 * @param int $id The ID of the item to retrieve the parent of.
47
	 */
48
	abstract public function get_parent_id( $id );
49
50
}
51