Carbon_Pagination_Item_Current_Page_Text::setup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 11
ccs 8
cts 8
cp 1
crap 1
rs 9.4285
1
<?php
2
/**
3
 * The Carbon Pagination current page item class.
4
 * Responsible for the "Page X of Y" pagination item.
5
 *
6
 * @uses Carbon_Pagination_Item
7
 */
8
class Carbon_Pagination_Item_Current_Page_Text extends Carbon_Pagination_Item {
9
10
	/**
11
	 * Setup the item before rendering.
12
	 * Setup item tokens.
13
	 */
14 2
	public function setup() {
15 2
		$pagination = $this->get_collection()->get_pagination();
16 2
		$current_page = $pagination->get_current_page();
17
18
		$tokens = array(
19 2
			'CURRENT_PAGE' => $current_page,
20 2
			'TOTAL_PAGES' => $pagination->get_total_pages(),
21 2
		);
22
23 2
		$this->set_tokens( $tokens );
24 2
	}
25
26
	/**
27
	 * Render the item.
28
	 *
29
	 * @return string $html The HTML of the item.
30
	 */
31 2
	public function render() {
32 2
		$pagination = $this->get_collection()->get_pagination();
33
34 2
		$html = $pagination->get_current_page_html();
35 2
		$html = apply_filters( 'carbon_pagination_current_page_text', $html, $this );
36
37 2
		return $html;
38
	}
39
40
}