Passed
Push — master ( 1d8d13...de8c14 )
by Jean-Christophe
04:21
created

HtmlToast::setContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
namespace Ajax\semantic\html\modules;
3
4
use Ajax\semantic\html\base\HtmlSemDoubleElement;
5
use Ajax\JsUtils;
6
use Ajax\service\JArray;
7
8
class HtmlToast extends HtmlSemDoubleElement {
9
	
10
	protected $_params=array();
11
	protected $_paramParts=array();
12
	public function __construct($identifier, $content="") {
13
		parent::__construct($identifier, "div","ui toast");
14
		if(isset($content)){
15
			$this->setContent($content);
16
		}
17
	}
18
	
19
	public function setContent($value) {
20
		$this->content["content"]=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", $value);
21
		return $this;
22
	}
23
	
24
	/**
25
	 *
26
	 * {@inheritDoc}
27
	 *
28
	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile()
29
	 */
30
	public function compile(JsUtils $js=NULL, &$view=NULL) {
31
		$this->content=JArray::sortAssociative($this->content, ["content","actions" ]);
32
		return parent::compile($js, $view);
33
	}
34
	/*
35
	 * (non-PHPdoc)
36
	 * @see BaseHtml::run()
37
	 */
38
	public function run(JsUtils $js) {
39
		if(isset($this->_bsComponent)===false)
40
			$this->_bsComponent=$js->semantic()->toast("#".$this->identifier,$this->_params,$this->_paramParts);
0 ignored issues
show
Unused Code introduced by
The call to Ajax\Semantic::toast() has too many arguments starting with $this->_paramParts. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
			$this->_bsComponent=$js->semantic()->/** @scrutinizer ignore-call */ toast("#".$this->identifier,$this->_params,$this->_paramParts);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
41
			$this->addEventsOnRun($js);
42
			return $this->_bsComponent;
43
	}
44
}
45
46