Passed
Push — master ( 42337f...468e47 )
by Jean-Christophe
02:24
created

HtmlPaginationMenu::setActivePage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Ajax\semantic\html\collections\menus;
4
5
use Ajax\JsUtils;
6
7
use Ajax\semantic\html\elements\HtmlIcon;
8
9
class HtmlPaginationMenu extends HtmlMenu{
10
	private $_page;
11
	private $_pages;
12
	private $_max;
13
	public function __construct( $identifier, $items=array() ){
14
		parent::__construct( $identifier,$items);
15
		$this->_pages=$items;
16
	}
17
	/**
18
	 * {@inheritDoc}
19
	 * @see \Ajax\common\html\BaseHtml::compile()
20
	 */
21
	public function compile(JsUtils $js=NULL,&$view=NULL){
22
		$max=$this->_max;//\sizeof($this->content);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
		foreach ($this->content as $item){
24
			$item->addClass("pageNum");
25
		}
26
		$this->insertItem(new HtmlIcon("", "left chevron"))->setProperty("data-page", \max([1,$this->_page-1]))->addToProperty("class","_firstPage no-active");
27
		$this->addItem(new HtmlIcon("", "right chevron"))->setProperty("data-page", \min([$max,$this->_page+1]))->setProperty("data-max", $max)->addToProperty("class","_lastPage no-active");
28
		$this->asPagination();
29
		return parent::compile($js,$view);
30
	}
31
32
	public function setActivePage($page){
33
		$index=$page-$this->_pages[0];
34
		$item=$this->setActiveItem($index);
0 ignored issues
show
Unused Code introduced by
The assignment to $item is dead and can be removed.
Loading history...
35
		$this->_page=$page;
36
		return $this;
37
	}
38
39
	public function getPage() {
40
		return $this->_page;
41
	}
42
	/**
43
	 * @param mixed $_max
44
	 */
45
	public function setMax($_max) {
46
		$this->_max = $_max;
47
	}
48
49
50
}
51