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

CSimpleTable   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 7
c 2
b 0
f 2
lcom 1
cbo 0
dl 0
loc 47
ccs 23
cts 23
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addRow() 0 4 1
A addHeadings() 0 4 1
B createTable() 0 27 4
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