Completed
Push — master ( 06f62d...424d4e )
by Jean-Christophe
03:13
created

HtmlSemNavElement::autoGetOnClick()   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 1
1
<?php
2
namespace Ajax\semantic\html\base;
3
4
use Ajax\JsUtils;
5
/**
6
 * Sem class for navigation elements : Breadcrumbs and Pagination
7
 * @author jc
8
 * @version 1.001
9
 */
10
abstract class HtmlSemNavElement extends HtmlSemCollection {
11
	/**
12
	 * @var string the root site
13
	 */
14
	protected $root;
15
16
	/**
17
	 * @var String the html attribute which contains the elements url. default : data-ajax
18
	 */
19
	protected $attr;
20
21
	protected $_contentSeparator="";
22
23
24
	public function __construct($identifier,$tagName,$baseClass){
25
		parent::__construct($identifier,$tagName,$baseClass);
26
		$this->root="";
27
		$this->attr="data-ajax";
28
	}
29
30
	/**
31
	 * Associate an ajax get to the elements, displayed in $targetSelector
32
	 * $attr member is used to build each element url
33
	 * @param string $targetSelector the target of the get
34
	 * @param string $attr the html attribute used to build the elements url
0 ignored issues
show
Bug introduced by
There is no parameter named $attr. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
35
	 * @return HtmlNavElement
36
	 */
37
	public function autoGetOnClick($targetSelector){
38
		return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr));
39
	}
40
41
	public function contentAsString(){
42
		return implode($this->_contentSeparator, $this->content);
43
	}
44
45
	/**
46
	 * Generate the jquery script to set the elements to the HtmlNavElement
47
	 * @param JsUtils $jsUtils
48
	 */
49
	public function jsSetContent(JsUtils $jsUtils){
50
		$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
51
	}
52
53
	public function getRoot() {
54
		return $this->root;
55
	}
56
	public function setRoot($root) {
57
		$this->root = $root;
58
		return $this;
59
	}
60
	public function getAttr() {
61
		return $this->attr;
62
	}
63
64
	/**
65
	 * Define the html attribute for each element url in ajax
66
	 * @param string $attr html attribute
67
	 * @return HtmlNavElement
68
	 */
69
	public function setAttr($attr) {
70
		$this->attr = $attr;
71
		return $this;
72
	}
73
74 View Code Duplication
	public function __call($method, $args) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
		if(isset($this->$method) && is_callable($this->$method)) {
76
			return call_user_func_array(
77
					$this->$method,
78
					$args
79
					);
80
		}
81
	}
82
83
	public abstract function fromDispatcher($dispatcher,$startIndex=0);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
84
85
86
	public function setContentSeparator($contentSeparator) {
87
		$this->_contentSeparator=$contentSeparator;
88
		return $this;
89
	}
90
91
92
}