Completed
Push — master ( 6e3264...0dd83f )
by Jean-Christophe
03:39
created

HtmlNavElement   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 2
cbo 2
dl 0
loc 74
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A autoGetOnClick() 0 3 1
A contentAsString() 0 3 1
A jsSetContent() 0 3 1
A getRoot() 0 3 1
A setRoot() 0 4 1
A getAttr() 0 3 1
A setAttr() 0 4 1
A __call() 0 8 3
fromDispatcher() 0 1 ?
1
<?php
2
namespace Ajax\bootstrap\html\base;
3
4
use Ajax\bootstrap\html\base\HtmlDoubleElement;
5
use Ajax\JsUtils;
0 ignored issues
show
Coding Style introduced by
As per PSR2, there should be exactly one blank line after the last USE statement, 0 were found though.
Loading history...
6
/**
7
 * Bse class for navigation elements : Breadcrumbs and Pagination
8
 * @author jc
9
 * @version 1.001
10
 */
11
abstract class HtmlNavElement extends HtmlDoubleElement {
1 ignored issue
show
Coding Style introduced by
As per PSR2, the opening brace for this class should be on a new line.
Loading history...
12
	/**
13
	 * @var string the root site
14
	 */
15
	protected $root;
16
	
17
	/**
18
	 * @var String the html attribute which contains the elements url. default : data-ajax
19
	 */
20
	protected $attr;
21
	
22
	
23
	public function __construct($identifier,$tagName){
24
		parent::__construct($identifier,$tagName);
25
		$this->root="";
26
		$this->attr="data-ajax";
27
	}
28
	
29
	/**
30
	 * Associate an ajax get to the elements, displayed in $targetSelector
31
	 * $attr member is used to build each element url
32
	 * @param string $targetSelector the target of the get
33
	 * @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...
34
	 * @return HtmlNavElement
35
	 */
36
	public function autoGetOnClick($targetSelector){
37
		return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr));
38
	}
39
	
40
	public function contentAsString(){
41
		return implode("", $this->content);
42
	}
43
	
44
	/**
45
	 * Generate the jquery script to set the elements to the HtmlNavElement
46
	 * @param JsUtils $jsUtils
47
	 */
48
	public function jsSetContent(JsUtils $jsUtils){
49
		$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
50
	}
51
	
52
	public function getRoot() {
53
		return $this->root;
54
	}
55
	public function setRoot($root) {
56
		$this->root = $root;
57
		return $this;
58
	}
59
	public function getAttr() {
60
		return $this->attr;
61
	}
62
	
63
	/**
64
	 * Define the html attribute for each element url in ajax
65
	 * @param string $attr html attribute
66
	 * @return HtmlNavElement
67
	 */
68
	public function setAttr($attr) {
69
		$this->attr = $attr;
70
		return $this;
71
	}
72
73
	public function __call($method, $args) {
74
		if(isset($this->$method) && is_callable($this->$method)) {
75
			return call_user_func_array(
76
					$this->$method,
77
					$args
78
					);
79
		}
80
	}
81
	
82
	public abstract function fromDispatcher($dispatcher);
0 ignored issues
show
Coding Style introduced by
The abstract declaration must precede the visibility declaration
Loading history...
83
	
84
}
1 ignored issue
show
Coding Style introduced by
According to PSR2, the closing brace of classes should be placed on the next line directly after the body.

Below you find some examples:

// Incorrect placement according to PSR2
class MyClass
{
    public function foo()
    {

    }
    // This blank line is not allowed.

}

// Correct
class MyClass
{
    public function foo()
    {

    } // No blank lines after this line.
}
Loading history...