CHTMLTable   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 5
c 3
b 1
f 0
lcom 1
cbo 0
dl 0
loc 42
ccs 19
cts 19
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getTable() 0 22 4
A __construct() 0 4 1
1
<?php
2
namespace Jovis\HTMLTable;
3
4
/** tar resultatet från en databasfråga och placerar ut i en HTML tabell, 
5
* inklusive länkar och hantering av paginering och sortering 
6
*
7
*/
8
9
class CHTMLTable{ 
10
  
11
  private $data;
12
  private $headline;
13
  
14
  //tar emot en headline som enkel array och data som tvådimensionell array
15 1
  public function __construct($headline, $data){
16 1
    $this->data = $data;
17 1
    $this->headline = $headline;
18 1
  }
19
 
20
 /**
21
  * skapar en tabell (sträng) med rubriker från den endimensionella 
22
  * arrayen $headline och innehåll från
23
  * den tvådimensionella arrayen $data array
24
  *
25
  * @return string $html, sträng innehållande en tabell
26
  */
27
   
28 1
  public function getTable(){
29
       
30
    $table = "<div class='dbtable'>
31
      <table class>
32 1
        <tr class='rows'>";
33
        
34 1
   foreach($this->headline as $h) {
35 1
      $table.= "<th>" . $h ."</th>";
36 1
     }
37
   
38 1
   $table .= "</tr>";
39 1
   foreach($this->data as $d){
40 1
     $table .= "<tr>";  
41 1
     foreach ($d as $v) {
42 1
       $table .= "<td>$v</td>";
43 1
     }
44 1
     $table .= "</tr>";
45 1
   }
46 1
   $table .="</table></div>";
47
    
48 1
   return $table;
49
  }
50
}
51