Completed
Push — master ( 03d1b2...8466ff )
by Jean-Christophe
03:11
created

HtmlGridRow::__construct()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.2
cc 4
eloc 13
nc 5
nop 3
1
<?php
2
3
namespace Ajax\semantic\html\content;
4
5
use Ajax\common\html\html5\HtmlCollection;
6
7
class HtmlGridRow extends HtmlCollection{
8
9
	private $_colSize;
10
	public function __construct( $identifier,$numCols=NULL,$colSizing=false){
11
		parent::__construct( $identifier,"div");
12
		$this->setClass("row");
13
		$width=null;
14
		if(isset($numCols)){
15
			$numCols=min(16,$numCols);
16
			$numCols=max(1,$numCols);
17
			if($colSizing)
18
				$width=(int)(16/$numCols);
19
			else
20
				$this->_colSize=16/$numCols;
21
			for ($i=0;$i<$numCols;$i++){
22
				$this->addItem($width);
23
			}
24
		}
25
	}
26
27
	/**
28
	 * return the col at $index
29
	 * @param int $index
30
	 * @return \Ajax\semantic\html\collections\HtmlGridCol
31
	 */
32
	public function getCol($index){
33
		return $this->getItem($index);
34
	}
35
36
	protected function createItem($value){
37
		$col=new HtmlGridCol($this->identifier."-col-".($this->count()+1),$value);
38
		return $col;
39
	}
40
}