Completed
Push — master ( 6831db...b65ced )
by Jean-Christophe
03:10
created
Ajax/common/html/BaseHtml.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -71,6 +71,10 @@  discard block
 block discarded – undo
71 71
 
72 72
 
73 73
 
74
+	/**
75
+	 * @param string $name
76
+	 * @param string[] $typeCtrl
77
+	 */
74 78
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
75 79
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
76 80
 			return $name=$value;
@@ -88,6 +92,10 @@  discard block
 block discarded – undo
88 92
 
89 93
 
90 94
 
95
+	/**
96
+	 * @param string $name
97
+	 * @param string[] $typeCtrl
98
+	 */
91 99
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
92 100
 		if ($this->ctrl($name, $value, $typeCtrl) === true) {
93 101
 			if (\is_array($typeCtrl)) {
@@ -98,6 +106,9 @@  discard block
 block discarded – undo
98 106
 		return $this;
99 107
 	}
100 108
 
109
+	/**
110
+	 * @param string $name
111
+	 */
101 112
 	protected function addToMember(&$name, $value, $separator=" ") {
102 113
 		$name=str_ireplace($value, "", $name) . $separator . $value;
103 114
 		return $this;
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @version 1.2
16 16
  */
17 17
 abstract class BaseHtml extends BaseWidget {
18
-	use BaseHtmlEventsTrait,BaseHtmlPropertiesTrait;
18
+	use BaseHtmlEventsTrait, BaseHtmlPropertiesTrait;
19 19
 	protected $_template;
20 20
 	protected $tagName;
21
-	protected $_wrapBefore=array ();
22
-	protected $_wrapAfter=array ();
21
+	protected $_wrapBefore=array();
22
+	protected $_wrapAfter=array();
23 23
 	protected $_bsComponent;
24 24
 
25 25
 	public function getBsComponent() {
@@ -32,24 +32,24 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	protected function getTemplate(JsUtils $js=NULL) {
35
-		return PropertyWrapper::wrap($this->_wrapBefore, $js) . $this->_template . PropertyWrapper::wrap($this->_wrapAfter, $js);
35
+		return PropertyWrapper::wrap($this->_wrapBefore, $js).$this->_template.PropertyWrapper::wrap($this->_wrapAfter, $js);
36 36
 	}
37 37
 
38 38
 	public function compile(JsUtils $js=NULL, &$view=NULL) {
39 39
 		$result=$this->getTemplate($js);
40
-		foreach ( $this as $key => $value ) {
41
-			if (JString::startswith($key, "_") === false && $key !== "events") {
40
+		foreach ($this as $key => $value) {
41
+			if (JString::startswith($key, "_")===false && $key!=="events") {
42 42
 				if (\is_array($value)) {
43 43
 					$v=PropertyWrapper::wrap($value, $js);
44 44
 				} else {
45 45
 					$v=$value;
46 46
 				}
47
-				$result=str_ireplace("%" . $key . "%", $v, $result);
47
+				$result=str_ireplace("%".$key."%", $v, $result);
48 48
 			}
49 49
 		}
50 50
 		if (isset($js)===true) {
51 51
 			$this->run($js);
52
-			if (isset($view) === true) {
52
+			if (isset($view)===true) {
53 53
 				$js->addViewElement($this->identifier, $result, $view);
54 54
 			}
55 55
 		}
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 
59 59
 	protected function ctrl($name, $value, $typeCtrl) {
60 60
 		if (\is_array($typeCtrl)) {
61
-			if (array_search($value, $typeCtrl) === false) {
62
-				throw new \Exception("La valeur passée `" . $value . "` à la propriété `" . $name . "` ne fait pas partie des valeurs possibles : {" . implode(",", $typeCtrl) . "}");
61
+			if (array_search($value, $typeCtrl)===false) {
62
+				throw new \Exception("La valeur passée `".$value."` à la propriété `".$name."` ne fait pas partie des valeurs possibles : {".implode(",", $typeCtrl)."}");
63 63
 			}
64 64
 		} else {
65 65
 			if (!$typeCtrl($value)) {
66
-				throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $name);
66
+				throw new \Exception("La fonction ".$typeCtrl." a retourné faux pour l'affectation de la propriété ".$name);
67 67
 			}
68 68
 		}
69 69
 		return true;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 
74 74
 	protected function setMemberCtrl(&$name, $value, $typeCtrl) {
75
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
75
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
76 76
 			return $name=$value;
77 77
 		}
78 78
 		return $this;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	protected function addToMemberUnique(&$name, $value, $typeCtrl, $separator=" ") {
82 82
 		if (\is_array($typeCtrl)) {
83 83
 			$this->removeOldValues($name, $typeCtrl);
84
-			$name.=$separator . $value;
84
+			$name.=$separator.$value;
85 85
 		}
86 86
 		return $this;
87 87
 	}
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 
90 90
 
91 91
 	protected function addToMemberCtrl(&$name, $value, $typeCtrl, $separator=" ") {
92
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
92
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
93 93
 			if (\is_array($typeCtrl)) {
94 94
 				$this->removeOldValues($name, $typeCtrl);
95 95
 			}
96
-			$name.=$separator . $value;
96
+			$name.=$separator.$value;
97 97
 		}
98 98
 		return $this;
99 99
 	}
100 100
 
101 101
 	protected function addToMember(&$name, $value, $separator=" ") {
102
-		$name=str_ireplace($value, "", $name) . $separator . $value;
102
+		$name=str_ireplace($value, "", $name).$separator.$value;
103 103
 		return $this;
104 104
 	}
105 105
 
@@ -127,26 +127,26 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	public function fromArray($array) {
130
-		foreach ( $this as $key => $value ) {
131
-			if(array_key_exists($key, $array)===true)
132
-				$this->_callSetter("set" . ucfirst($key), $key, $array[$key], $array);
130
+		foreach ($this as $key => $value) {
131
+			if (array_key_exists($key, $array)===true)
132
+				$this->_callSetter("set".ucfirst($key), $key, $array[$key], $array);
133 133
 		}
134
-		foreach ( $array as $key => $value ) {
135
-			if($this->_callSetter($key, $key, $value, $array)===false){
136
-				$this->_callSetter("set" . ucfirst($key), $key, $value, $array);
134
+		foreach ($array as $key => $value) {
135
+			if ($this->_callSetter($key, $key, $value, $array)===false) {
136
+				$this->_callSetter("set".ucfirst($key), $key, $value, $array);
137 137
 			}
138 138
 		}
139 139
 		return $array;
140 140
 	}
141 141
 
142
-	private function _callSetter($setter,$key,$value,&$array){
142
+	private function _callSetter($setter, $key, $value, &$array) {
143 143
 		$result=false;
144 144
 		if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
145 145
 			try {
146 146
 				$this->$setter($value);
147 147
 				unset($array[$key]);
148 148
 				$result=true;
149
-			} catch ( \Exception $e ) {
149
+			}catch (\Exception $e) {
150 150
 				$result=false;
151 151
 			}
152 152
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 	public function fromDatabaseObjects($objects, $function) {
157 157
 		if (isset($objects)) {
158
-			foreach ( $objects as $object ) {
158
+			foreach ($objects as $object) {
159 159
 				$this->fromDatabaseObject($object, $function);
160 160
 			}
161 161
 		}
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 		if (\is_array($elements)) {
180 180
 			$flag=false;
181 181
 			$index=0;
182
-			while ( !$flag && $index < sizeof($elements) ) {
182
+			while (!$flag && $index<sizeof($elements)) {
183 183
 				if ($elements[$index] instanceof BaseHtml)
184
-					$flag=($elements[$index]->getIdentifier() === $identifier);
184
+					$flag=($elements[$index]->getIdentifier()===$identifier);
185 185
 				$index++;
186 186
 			}
187
-			if ($flag === true)
188
-				return $elements[$index - 1];
187
+			if ($flag===true)
188
+				return $elements[$index-1];
189 189
 		} elseif ($elements instanceof BaseHtml) {
190
-			if ($elements->getIdentifier() === $identifier)
190
+			if ($elements->getIdentifier()===$identifier)
191 191
 				return $elements;
192 192
 		}
193 193
 		return null;
Please login to merge, or discard this patch.
Ajax/common/html/traits/BaseHtmlPropertiesTrait.php 2 patches
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -52,11 +52,17 @@  discard block
 block discarded – undo
52 52
 		return $this;
53 53
 	}
54 54
 
55
+	/**
56
+	 * @param string $name
57
+	 */
55 58
 	protected function removePropertyValue($name, $value) {
56 59
 		$this->properties[$name]=\str_replace($value, "", $this->properties[$name]);
57 60
 		return $this;
58 61
 	}
59 62
 
63
+	/**
64
+	 * @param string $name
65
+	 */
60 66
 	protected function removePropertyValues($name, $values) {
61 67
 		$this->removeOldValues($this->properties[$name], $values);
62 68
 		return $this;
@@ -71,6 +77,9 @@  discard block
 block discarded – undo
71 77
 			return $this->addToProperty($name, $value);
72 78
 	}
73 79
 
80
+	/**
81
+	 * @param string $name
82
+	 */
74 83
 	public function addToPropertyCtrl($name, $value, $typeCtrl) {
75 84
 		return $this->addToPropertyUnique($name, $value, $typeCtrl);
76 85
 	}
@@ -82,6 +91,9 @@  discard block
 block discarded – undo
82 91
 		return $this;
83 92
 	}
84 93
 
94
+	/**
95
+	 * @param string $name
96
+	 */
85 97
 	public function removeProperty($name) {
86 98
 		if (\array_key_exists($name, $this->properties))
87 99
 			unset($this->properties[$name]);
@@ -102,6 +114,10 @@  discard block
 block discarded – undo
102 114
 			return $this;
103 115
 	}
104 116
 
117
+	/**
118
+	 * @param string $propertyName
119
+	 * @param string $value
120
+	 */
105 121
 	protected function getElementByPropertyValue($propertyName,$value, $elements) {
106 122
 		if (\is_array($elements)) {
107 123
 			$flag=false;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
  * @author jc
8 8
  *
9 9
  */
10
-trait BaseHtmlPropertiesTrait{
10
+trait BaseHtmlPropertiesTrait {
11 11
 
12
-	protected $properties=array ();
12
+	protected $properties=array();
13 13
 	abstract protected function ctrl($name, $value, $typeCtrl);
14 14
 	public function getProperties() {
15 15
 		return $this->properties;
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 
33 33
 	public function addToProperty($name, $value, $separator=" ") {
34 34
 		if (\is_array($value)) {
35
-			foreach ( $value as $v ) {
35
+			foreach ($value as $v) {
36 36
 				$this->addToProperty($name, $v, $separator);
37 37
 			}
38
-		} else if ($value !== "" && $this->propertyContains($name, $value) === false) {
38
+		} else if ($value!=="" && $this->propertyContains($name, $value)===false) {
39 39
 			$v=@$this->properties[$name];
40
-			if (isset($v) && $v !== "")
41
-				$v=$v . $separator . $value;
40
+			if (isset($v) && $v!=="")
41
+				$v=$v.$separator.$value;
42 42
 				else
43 43
 					$v=$value;
44 44
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	public function addToPropertyCtrlCheck($name, $value, $typeCtrl) {
79
-		if ($this->ctrl($name, $value, $typeCtrl) === true) {
79
+		if ($this->ctrl($name, $value, $typeCtrl)===true) {
80 80
 			return $this->addToProperty($name, $value);
81 81
 		}
82 82
 		return $this;
@@ -97,24 +97,24 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	protected function setPropertyCtrl($name, $value, $typeCtrl) {
100
-		if ($this->ctrl($name, $value, $typeCtrl) === true)
100
+		if ($this->ctrl($name, $value, $typeCtrl)===true)
101 101
 			return $this->setProperty($name, $value);
102 102
 			return $this;
103 103
 	}
104 104
 
105
-	protected function getElementByPropertyValue($propertyName,$value, $elements) {
105
+	protected function getElementByPropertyValue($propertyName, $value, $elements) {
106 106
 		if (\is_array($elements)) {
107 107
 			$flag=false;
108 108
 			$index=0;
109
-			while ( !$flag && $index < sizeof($elements) ) {
109
+			while (!$flag && $index<sizeof($elements)) {
110 110
 				if ($elements[$index] instanceof BaseHtml)
111
-					$flag=($elements[$index]->propertyContains($propertyName, $value) === true);
111
+					$flag=($elements[$index]->propertyContains($propertyName, $value)===true);
112 112
 					$index++;
113 113
 			}
114
-			if ($flag === true)
115
-				return $elements[$index - 1];
114
+			if ($flag===true)
115
+				return $elements[$index-1];
116 116
 		} elseif ($elements instanceof BaseHtml) {
117
-			if ($elements->propertyContains($propertyName, $value) === true)
117
+			if ($elements->propertyContains($propertyName, $value)===true)
118 118
 				return $elements;
119 119
 		}
120 120
 		return null;
Please login to merge, or discard this patch.