Completed
Push — master ( 3555a5...e61355 )
by Jean-Christophe
03:33
created

HtmlPaginationMenu   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A compile() 0 6 1
A setActiveItem() 0 5 1
A getPage() 0 3 1
1
<?php
2
3
namespace Ajax\semantic\html\collections\menus;
4
5
use Ajax\semantic\html\collections\menus\HtmlMenu;
6
use Ajax\JsUtils;
7
8
use Ajax\semantic\html\elements\HtmlIcon;
9
10
class HtmlPaginationMenu extends HtmlMenu{
11
	private $_page;
12
	public function __construct( $identifier, $items=array() ){
13
		parent::__construct( $identifier,$items);
14
	}
15
	/**
16
	 * {@inheritDoc}
17
	 * @see \Ajax\common\html\BaseHtml::compile()
18
	 */
19
	public function compile(JsUtils $js=NULL,&$view=NULL){
20
		$this->insertItem(new HtmlIcon("", "left chevron"))->setProperty("data-page", \max([1,$this->_page-1]));
21
		$this->addItem(new HtmlIcon("", "right chevron"))->setProperty("data-page", \min([\sizeof($this->content)-2,$this->_page+1]));
22
		$this->asPagination();
23
		return parent::compile($js,$view);
24
	}
25
26
	public function setActiveItem($index) {
27
		$result=parent::setActiveItem($index);
28
		$this->_page=$index+1;
29
		return $result;
30
	}
31
32
	public function getPage() {
33
		return $this->_page;
34
	}
35
36
}