Passed
Push — master ( a3f400...94fae6 )
by Jean-Christophe
03:34
created
Ajax/semantic/html/content/table/HtmlTableContent.php 2 patches
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class HtmlTableContent extends HtmlSemCollection {
17 17
 
18
-	protected $_focusable = false;
18
+	protected $_focusable=false;
19 19
 
20
-	protected $_tdTagNames = [
20
+	protected $_tdTagNames=[
21 21
 		"thead" => "th",
22 22
 		"tbody" => "td",
23 23
 		"tfoot" => "th"
24 24
 	];
25 25
 
26
-	protected $_merged = false;
26
+	protected $_merged=false;
27 27
 
28 28
 	/**
29 29
 	 *
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param int $rowCount
33 33
 	 * @param int $colCount
34 34
 	 */
35
-	public function __construct($identifier, $tagName = "tbody", $rowCount = NULL, $colCount = NULL) {
35
+	public function __construct($identifier, $tagName="tbody", $rowCount=NULL, $colCount=NULL) {
36 36
 		parent::__construct($identifier, $tagName, "");
37 37
 		if (isset($rowCount) && isset($colCount))
38 38
 			$this->setRowCount($rowCount, $colCount);
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @return HtmlTableContent
46 46
 	 */
47 47
 	public function setRowCount($rowCount, $colCount) {
48
-		$count = $this->count();
49
-		for ($i = $count; $i < $rowCount; $i ++) {
48
+		$count=$this->count();
49
+		for ($i=$count; $i<$rowCount; $i++) {
50 50
 			$this->addItem($colCount);
51 51
 		}
52 52
 		return $this;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	}
58 58
 
59 59
 	public function refreshTR() {
60
-		$this->_template = "%wrapContentBefore%%content%%wrapContentAfter%";
60
+		$this->_template="%wrapContentBefore%%content%%wrapContentAfter%";
61 61
 	}
62 62
 
63 63
 	/**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 * @return HtmlTR
69 69
 	 */
70 70
 	protected function createItem($value) {
71
-		$count = $this->count();
72
-		$tr = new HtmlTR("");
71
+		$count=$this->count();
72
+		$tr=new HtmlTR("");
73 73
 		$tr->setContainer($this, $count);
74 74
 		if ($this->_focusable) {
75 75
 			$tr->setProperty('tabindex', $count);
76 76
 		}
77 77
 		$tr->setTdTagName($this->_tdTagNames[$this->tagName]);
78
-		if (isset($value) === true) {
78
+		if (isset($value)===true) {
79 79
 			$tr->setColCount($value);
80 80
 		}
81 81
 		return $tr;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		return $this->addItem($row);
104 104
 	}
105 105
 
106
-	public function addMergeRow($colCount, $value = null) {
107
-		$row = $this->addRow($colCount);
106
+	public function addMergeRow($colCount, $value=null) {
107
+		$row=$this->addRow($colCount);
108 108
 		$row->mergeCol();
109 109
 		if (isset($value)) {
110 110
 			$row->setValues([
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 	 * @return HtmlTD|HtmlDoubleElement
131 131
 	 */
132 132
 	public function getCell($row, $col) {
133
-		$row = $this->getItem($row);
133
+		$row=$this->getItem($row);
134 134
 		if (isset($row) && $row instanceof HtmlCollection) {
135
-			$col = $row->getItem($col);
135
+			$col=$row->getItem($col);
136 136
 		} else {
137
-			$col = $row;
137
+			$col=$row;
138 138
 		}
139 139
 		return $col;
140 140
 	}
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 * @param mixed $value
156 156
 	 * @return HtmlTableContent
157 157
 	 */
158
-	public function setCellValue($row, $col, $value = "") {
159
-		$cell = $this->getCell($row, $col);
160
-		if (isset($cell) === true) {
158
+	public function setCellValue($row, $col, $value="") {
159
+		$cell=$this->getCell($row, $col);
160
+		if (isset($cell)===true) {
161 161
 			$cell->setValue($value);
162 162
 		}
163 163
 		return $this;
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @param mixed $values
170 170
 	 */
171
-	public function setValues($values = array()) {
172
-		return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) {
171
+	public function setValues($values=array()) {
172
+		return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {
173 173
 			$row->setValues($_values);
174 174
 		});
175 175
 	}
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param mixed $values
181 181
 	 */
182
-	public function addValues($values = array()) {
183
-		return $this->_addOrSetValues($values, function (HtmlTR $row, $_values) {
182
+	public function addValues($values=array()) {
183
+		return $this->_addOrSetValues($values, function(HtmlTR $row, $_values) {
184 184
 			$row->addValues($_values);
185 185
 		});
186 186
 	}
@@ -192,42 +192,42 @@  discard block
 block discarded – undo
192 192
 	 * @param callable $callback
193 193
 	 */
194 194
 	protected function _addOrSetValues($values, $callback) {
195
-		$count = $this->count();
196
-		$isArray = true;
197
-		if (! \is_array($values)) {
198
-			$values = \array_fill(0, $count, $values);
199
-			$isArray = false;
195
+		$count=$this->count();
196
+		$isArray=true;
197
+		if (!\is_array($values)) {
198
+			$values=\array_fill(0, $count, $values);
199
+			$isArray=false;
200 200
 		}
201
-		if (JArray::dimension($values) == 1 && $isArray)
202
-			$values = [
201
+		if (JArray::dimension($values)==1 && $isArray)
202
+			$values=[
203 203
 				$values
204 204
 			];
205 205
 
206
-		$count = \min(\sizeof($values), $count);
206
+		$count=\min(\sizeof($values), $count);
207 207
 
208
-		for ($i = 0; $i < $count; $i ++) {
209
-			$row = $this->content[$i];
208
+		for ($i=0; $i<$count; $i++) {
209
+			$row=$this->content[$i];
210 210
 			$callback($row, $values[$i]);
211 211
 		}
212 212
 		return $this;
213 213
 	}
214 214
 
215
-	public function setColValues($colIndex, $values = array()) {
216
-		$count = $this->count();
217
-		if (! \is_array($values)) {
218
-			$values = \array_fill(0, $count, $values);
215
+	public function setColValues($colIndex, $values=array()) {
216
+		$count=$this->count();
217
+		if (!\is_array($values)) {
218
+			$values=\array_fill(0, $count, $values);
219 219
 		}
220
-		$count = \min(\sizeof($values), $count);
221
-		for ($i = 0; $i < $count; $i ++) {
220
+		$count=\min(\sizeof($values), $count);
221
+		for ($i=0; $i<$count; $i++) {
222 222
 			$this->getCell($i, $colIndex)->setValue($values[$i]);
223 223
 		}
224 224
 		return $this;
225 225
 	}
226 226
 
227
-	public function addColVariations($colIndex, $variations = array()) {
228
-		$count = $this->count();
229
-		for ($i = 0; $i < $count; $i ++) {
230
-			$cell = $this->getCell($i, $colIndex);
227
+	public function addColVariations($colIndex, $variations=array()) {
228
+		$count=$this->count();
229
+		for ($i=0; $i<$count; $i++) {
230
+			$cell=$this->getCell($i, $colIndex);
231 231
 			if ($cell instanceof BaseTrait)
232 232
 				$cell->addVariations($variations);
233 233
 		}
@@ -235,31 +235,31 @@  discard block
 block discarded – undo
235 235
 	}
236 236
 
237 237
 	public function addPropertyCol($colIndex, $name, $value) {
238
-		$count = $this->count();
239
-		for ($i = 0; $i < $count; $i ++) {
240
-			$cell = $this->getCell($i, $colIndex);
238
+		$count=$this->count();
239
+		for ($i=0; $i<$count; $i++) {
240
+			$cell=$this->getCell($i, $colIndex);
241 241
 			if (isset($cell))
242 242
 				$cell->addToProperty($name, $value);
243 243
 		}
244 244
 		return $this;
245 245
 	}
246 246
 
247
-	public function setRowValues($rowIndex, $values = array()) {
248
-		$count = $this->count();
249
-		if (! \is_array($values)) {
250
-			$values = \array_fill(0, $count, $values);
247
+	public function setRowValues($rowIndex, $values=array()) {
248
+		$count=$this->count();
249
+		if (!\is_array($values)) {
250
+			$values=\array_fill(0, $count, $values);
251 251
 		}
252 252
 		$this->getItem($rowIndex)->setValues($values);
253 253
 		return $this;
254 254
 	}
255 255
 
256 256
 	private function colAlign($colIndex, $function) {
257
-		$count = $this->count();
258
-		for ($i = 0; $i < $count; $i ++) {
259
-			$index = $this->content[$i]->getColPosition($colIndex);
260
-			if ($index !== NULL) {
261
-				$cell = $this->getCell($i, $index);
262
-				if ($cell != NULL) {
257
+		$count=$this->count();
258
+		for ($i=0; $i<$count; $i++) {
259
+			$index=$this->content[$i]->getColPosition($colIndex);
260
+			if ($index!==NULL) {
261
+				$cell=$this->getCell($i, $index);
262
+				if ($cell!=NULL) {
263 263
 					$cell->$function();
264 264
 				}
265 265
 			}
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	}
269 269
 
270 270
 	private function colAlignFromRight($colIndex, $function) {
271
-		$count = $this->count();
272
-		for ($i = 0; $i < $count; $i ++) {
273
-			$maxRow = $this->content[$i]->count();
274
-			$index = $maxRow - $colIndex - 1;
275
-			if (($cell = $this->getCell($i, $index)) !== NULL) {
276
-				if ($cell->getColspan() == 1)
271
+		$count=$this->count();
272
+		for ($i=0; $i<$count; $i++) {
273
+			$maxRow=$this->content[$i]->count();
274
+			$index=$maxRow-$colIndex-1;
275
+			if (($cell=$this->getCell($i, $index))!==NULL) {
276
+				if ($cell->getColspan()==1)
277 277
 					$cell->$function();
278 278
 			}
279 279
 		}
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
 	 * @return int
320 320
 	 */
321 321
 	public function getColCount() {
322
-		$result = 0;
323
-		if ($this->count() > 0)
324
-			$result = $this->getItem(0)->count();
322
+		$result=0;
323
+		if ($this->count()>0)
324
+			$result=$this->getItem(0)->count();
325 325
 		return $result;
326 326
 	}
327 327
 
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
 	 * @param int $colIndex
333 333
 	 * @return HtmlTableContent
334 334
 	 */
335
-	public function delete($rowIndex, $colIndex = NULL) {
335
+	public function delete($rowIndex, $colIndex=NULL) {
336 336
 		if (isset($colIndex)) {
337
-			$row = $this->getItem($rowIndex);
338
-			if (isset($row) === true) {
337
+			$row=$this->getItem($rowIndex);
338
+			if (isset($row)===true) {
339 339
 				$row->delete($colIndex);
340 340
 			}
341 341
 		} else {
@@ -345,24 +345,24 @@  discard block
 block discarded – undo
345 345
 	}
346 346
 
347 347
 	public function toDelete($rowIndex, $colIndex) {
348
-		$row = $this->getItem($rowIndex);
349
-		if (isset($row) === true)
348
+		$row=$this->getItem($rowIndex);
349
+		if (isset($row)===true)
350 350
 			$row->toDelete($colIndex);
351 351
 		return $this;
352 352
 	}
353 353
 
354 354
 	public function toRowspanned($rowIndex, $colIndex) {
355
-		$row = $this->getItem($rowIndex);
356
-		if (isset($row) === true)
355
+		$row=$this->getItem($rowIndex);
356
+		if (isset($row)===true)
357 357
 			$row->toRowspanned($colIndex);
358 358
 		return $this;
359 359
 	}
360 360
 
361
-	public function mergeCol($rowIndex = 0, $colIndex = 0) {
361
+	public function mergeCol($rowIndex=0, $colIndex=0) {
362 362
 		return $this->getItem($rowIndex)->mergeCol($colIndex);
363 363
 	}
364 364
 
365
-	public function mergeRow($rowIndex = 0, $colIndex = 0) {
365
+	public function mergeRow($rowIndex=0, $colIndex=0) {
366 366
 		return $this->getItem($rowIndex)->mergeRow($colIndex);
367 367
 	}
368 368
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @return HtmlTableContent
383 383
 	 */
384 384
 	public function conditionalCellFormat($callback, $format) {
385
-		$rows = $this->content;
385
+		$rows=$this->content;
386 386
 		foreach ($rows as $row) {
387 387
 			$row->conditionalCellFormat($callback, $format);
388 388
 		}
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
 	}
391 391
 
392 392
 	public function conditionalColFormat($colIndex, $callback, $format) {
393
-		$rows = $this->content;
393
+		$rows=$this->content;
394 394
 		foreach ($rows as $row) {
395
-			$cell = $row->getItem($colIndex);
395
+			$cell=$row->getItem($colIndex);
396 396
 			$cell->conditionnalCellFormat($callback, $format);
397 397
 		}
398 398
 		return $this;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return HtmlTableContent
406 406
 	 */
407 407
 	public function conditionalRowFormat($callback, $format) {
408
-		$rows = $this->content;
408
+		$rows=$this->content;
409 409
 		foreach ($rows as $row) {
410 410
 			$row->conditionalRowFormat($callback, $format);
411 411
 		}
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
 	}
414 414
 
415 415
 	public function hideColumn($colIndex) {
416
-		$rows = $this->content;
416
+		$rows=$this->content;
417 417
 		foreach ($rows as $row) {
418
-			$cell = $row->getItem($colIndex);
418
+			$cell=$row->getItem($colIndex);
419 419
 			$cell->addToProperty("style", "display:none;");
420 420
 		}
421 421
 		return $this;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 * @return HtmlTableContent
428 428
 	 */
429 429
 	public function applyCells($callback) {
430
-		$rows = $this->content;
430
+		$rows=$this->content;
431 431
 		foreach ($rows as $row) {
432 432
 			$row->applyCells($callback);
433 433
 		}
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 * @return HtmlTableContent
441 441
 	 */
442 442
 	public function applyRows($callback) {
443
-		$rows = $this->content;
443
+		$rows=$this->content;
444 444
 		foreach ($rows as $row) {
445 445
 			$row->apply($callback);
446 446
 		}
@@ -455,28 +455,28 @@  discard block
 block discarded – undo
455 455
 	 * @see https://fomantic-ui.com/collections/table.html#definition needs rowspanned class
456 456
 	 * @since fomantic-ui 2.4.8
457 457
 	 */
458
-	public function mergeIdentiqualValues($colIndex, $function = "strip_tags") {
459
-		$rows = $this->content;
460
-		$identiqual = null;
461
-		$counter = 0;
462
-		$cellToMerge = null;
463
-		$functionExists = \function_exists($function);
458
+	public function mergeIdentiqualValues($colIndex, $function="strip_tags") {
459
+		$rows=$this->content;
460
+		$identiqual=null;
461
+		$counter=0;
462
+		$cellToMerge=null;
463
+		$functionExists=\function_exists($function);
464 464
 		foreach ($rows as $row) {
465
-			$cell = $row->getItem($colIndex);
466
-			$value = $cell->getContent();
465
+			$cell=$row->getItem($colIndex);
466
+			$value=$cell->getContent();
467 467
 			if ($functionExists)
468
-				$value = \call_user_func($function, $value);
469
-			if ($value !== $identiqual) {
470
-				if ($counter > 0 && isset($cellToMerge)) {
468
+				$value=\call_user_func($function, $value);
469
+			if ($value!==$identiqual) {
470
+				if ($counter>0 && isset($cellToMerge)) {
471 471
 					$cellToMerge->setRowspanned($counter);
472 472
 				}
473
-				$counter = 0;
474
-				$cellToMerge = $cell;
475
-				$identiqual = $value;
473
+				$counter=0;
474
+				$cellToMerge=$cell;
475
+				$identiqual=$value;
476 476
 			}
477
-			$counter ++;
477
+			$counter++;
478 478
 		}
479
-		if ($counter > 0 && isset($cellToMerge)) {
479
+		if ($counter>0 && isset($cellToMerge)) {
480 480
 			$cellToMerge->setRowspanned($counter);
481 481
 		}
482 482
 		return $this;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	}
488 488
 
489 489
 	public function _setMerged($value) {
490
-		$this->_merged = $value;
490
+		$this->_merged=$value;
491 491
 		return $this;
492 492
 	}
493 493
 
@@ -496,6 +496,6 @@  discard block
 block discarded – undo
496 496
 	 * @param bool $focusable
497 497
 	 */
498 498
 	public function setFocusable(bool $focusable): void {
499
-		$this->_focusable = $focusable;
499
+		$this->_focusable=$focusable;
500 500
 	}
501 501
 }
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function __construct($identifier, $tagName = "tbody", $rowCount = NULL, $colCount = NULL) {
36 36
 		parent::__construct($identifier, $tagName, "");
37
-		if (isset($rowCount) && isset($colCount))
38
-			$this->setRowCount($rowCount, $colCount);
37
+		if (isset($rowCount) && isset($colCount)) {
38
+					$this->setRowCount($rowCount, $colCount);
39
+		}
39 40
 	}
40 41
 
41 42
 	/**
@@ -198,10 +199,11 @@  discard block
 block discarded – undo
198 199
 			$values = \array_fill(0, $count, $values);
199 200
 			$isArray = false;
200 201
 		}
201
-		if (JArray::dimension($values) == 1 && $isArray)
202
-			$values = [
202
+		if (JArray::dimension($values) == 1 && $isArray) {
203
+					$values = [
203 204
 				$values
204 205
 			];
206
+		}
205 207
 
206 208
 		$count = \min(\sizeof($values), $count);
207 209
 
@@ -228,8 +230,9 @@  discard block
 block discarded – undo
228 230
 		$count = $this->count();
229 231
 		for ($i = 0; $i < $count; $i ++) {
230 232
 			$cell = $this->getCell($i, $colIndex);
231
-			if ($cell instanceof BaseTrait)
232
-				$cell->addVariations($variations);
233
+			if ($cell instanceof BaseTrait) {
234
+							$cell->addVariations($variations);
235
+			}
233 236
 		}
234 237
 		return $this;
235 238
 	}
@@ -238,8 +241,9 @@  discard block
 block discarded – undo
238 241
 		$count = $this->count();
239 242
 		for ($i = 0; $i < $count; $i ++) {
240 243
 			$cell = $this->getCell($i, $colIndex);
241
-			if (isset($cell))
242
-				$cell->addToProperty($name, $value);
244
+			if (isset($cell)) {
245
+							$cell->addToProperty($name, $value);
246
+			}
243 247
 		}
244 248
 		return $this;
245 249
 	}
@@ -273,8 +277,9 @@  discard block
 block discarded – undo
273 277
 			$maxRow = $this->content[$i]->count();
274 278
 			$index = $maxRow - $colIndex - 1;
275 279
 			if (($cell = $this->getCell($i, $index)) !== NULL) {
276
-				if ($cell->getColspan() == 1)
277
-					$cell->$function();
280
+				if ($cell->getColspan() == 1) {
281
+									$cell->$function();
282
+				}
278 283
 			}
279 284
 		}
280 285
 		return $this;
@@ -320,8 +325,9 @@  discard block
 block discarded – undo
320 325
 	 */
321 326
 	public function getColCount() {
322 327
 		$result = 0;
323
-		if ($this->count() > 0)
324
-			$result = $this->getItem(0)->count();
328
+		if ($this->count() > 0) {
329
+					$result = $this->getItem(0)->count();
330
+		}
325 331
 		return $result;
326 332
 	}
327 333
 
@@ -346,15 +352,17 @@  discard block
 block discarded – undo
346 352
 
347 353
 	public function toDelete($rowIndex, $colIndex) {
348 354
 		$row = $this->getItem($rowIndex);
349
-		if (isset($row) === true)
350
-			$row->toDelete($colIndex);
355
+		if (isset($row) === true) {
356
+					$row->toDelete($colIndex);
357
+		}
351 358
 		return $this;
352 359
 	}
353 360
 
354 361
 	public function toRowspanned($rowIndex, $colIndex) {
355 362
 		$row = $this->getItem($rowIndex);
356
-		if (isset($row) === true)
357
-			$row->toRowspanned($colIndex);
363
+		if (isset($row) === true) {
364
+					$row->toRowspanned($colIndex);
365
+		}
358 366
 		return $this;
359 367
 	}
360 368
 
@@ -464,8 +472,9 @@  discard block
 block discarded – undo
464 472
 		foreach ($rows as $row) {
465 473
 			$cell = $row->getItem($colIndex);
466 474
 			$value = $cell->getContent();
467
-			if ($functionExists)
468
-				$value = \call_user_func($function, $value);
475
+			if ($functionExists) {
476
+							$value = \call_user_func($function, $value);
477
+			}
469 478
 			if ($value !== $identiqual) {
470 479
 				if ($counter > 0 && isset($cellToMerge)) {
471 480
 					$cellToMerge->setRowspanned($counter);
Please login to merge, or discard this patch.