Carbon_Pagination_Item_Direction_Page::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 3
b 0
f 0
nc 2
nop 0
dl 0
loc 14
ccs 9
cts 9
cp 1
crap 2
rs 9.4285
1
<?php
2
/**
3
 * The Carbon Pagination direction page item class.
4
 * Used for prev, next, first & last items.
5
 * Should be extended by each one of them.
6
 *
7
 * @abstract
8
 *
9
 * @uses Carbon_Pagination_Item
10
 */
11
abstract class Carbon_Pagination_Item_Direction_Page extends Carbon_Pagination_Item {
12
13
	/**
14
	 * Initialize the item.
15
	 * Generate the sub items of this item.
16
	 */
17 2
	public function init() {
18 2
		$collection = $this->get_collection();
19
20
		// bail if this direction is disabled
21 2
		if ( $this->get_direction_disabled() ) {
22 2
			return;
23
		}
24
25
		// create subitem and its collection and assign it
26 1
		$html = $this->get_direction_html();
27 1
		$page = $this->get_direction_page_number();
28 1
		$subitems_collection = Carbon_Pagination_Item_Page::generate_single_subitem_collection( $collection, $html, $page );
29 1
		$this->set_subitems_collection( $subitems_collection );
30 1
	}
31
32
	/**
33
	 * The HTML of the direction item.
34
	 *
35
	 * @abstract
36
	 * @return string $html The direction item HTML.
37
	 */
38
	abstract public function get_direction_html();
39
	
40
	/**
41
	 * The result of the condition which would disable this item.
42
	 * If true, this item wont be displayed.
43
	 *
44
	 * @abstract
45
	 * @return bool $result The condition result.
46
	 */
47
	abstract public function get_direction_disabled();
48
49
	/**
50
	 * The number of the page to link to.
51
	 *
52
	 * @abstract
53
	 * @return int $page The number of the page to link to.
54
	 */
55
	abstract public function get_direction_page_number();
56
57
}