Completed
Push — master ( a06482...af47b7 )
by Patrik
02:11
created

CSimpleTable::addHeadings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace pbk83\SimpleTable;
4
5
/**
6
 * Class for creating a simple html - table
7
 *
8
 */
9
 
10
class CSimpleTable
11
{
12
	private $headings;
13
	private $rows = array();
14
	
15 1
	public function __construct($options = [])
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
	{
17 1
	}
18
	
19 1
	public function addRow($row)
20
	{
21 1
		$this->rows[] = $row;
22 1
	}
23
	
24 1
	public function addHeadings($head)
25
	{
26 1
		$this->headings = $head;
27 1
	}
28
	
29 1
	public function createTable()
30
	{
31
		$html = 
32
		'<table style="width:100%;border: 1px solid black;border-collapse: collapse;">
33 1
			<tr>';
34
				
35 1
		foreach($this->headings as $h)
36
		{
37 1
			$html .= '<th style="border: 1px solid black;border-collapse: collapse;">'.$h.'</th>';				
38 1
		}
39
		
40 1
		$html .=	'</tr>';
41
		
42 1
		foreach($this->rows as $row)
43
		{
44 1
			$html .= '<tr>';
45 1
			foreach($row as $r)
46
			{
47 1
				$html .= '<td style="border: 1px solid black;border-collapse: collapse;">' . $r . '</td>';
48 1
			}
49 1
			$html .= '</tr>';
50 1
		}
51
			
52 1
		$html .= '</table>';
53
		
54 1
		return $html;
55
	}
56
}
57