Completed
Push — master ( 1d23a1...916f6f )
by Jean-Christophe
03:30
created

HtmlRating::asStar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ajax\semantic\html\modules;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\JsUtils;
7
8
class HtmlRating extends HtmlSemDoubleElement {
9
	protected $_params=array();
10
	/**
11
	 * @param string $identifier
12
	 * @param int $value
13
	 * @param int $max
14
	 * @param string $icon star or heart
15
	 */
16
	public function __construct($identifier, $value,$max=5,$icon="") {
17
		parent::__construct($identifier, "div", "ui {$icon} rating");
18
		$this->setValue($value);
19
		$this->setMax($max);
20
	}
21
22
	/**
23
	 * {@inheritDoc}
24
	 * @see \Ajax\common\html\HtmlDoubleElement::setValue()
25
	 */
26
	public function setValue($value){
27
		$this->setProperty("data-rating", $value);
28
	}
29
30
	public function setMax($max){
31
		$this->setProperty("data-max-rating", $max);
32
	}
33
34
	/**
35
	 * {@inheritDoc}
36
	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
37
	 */
38
	public function run(JsUtils $js){
39
		parent::run($js);
40
		return $js->semantic()->rating("#".$this->identifier,$this->_params);
41
	}
42
43
	public function asStar(){
44
		return $this->setIcon();
45
	}
46
47
	public function asHeart(){
48
		return $this->setIcon("heart");
49
	}
50
51
	public function setIcon($icon="star"){
52
		return $this->addToPropertyCtrl("class", $icon, ["star","heart",""]);
53
	}
54
}