Passed
Push — master ( cb2842...994f5c )
by Patrick
02:04
created

TrapDirectorTableGrouping   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setGrouping() 0 4 1
A groupingPrintData() 0 4 1
A initGrouping() 0 4 1
A groupingNextLine() 0 12 4
1
<?php
2
3
namespace Icinga\Module\Trapdirector\Tables;
4
5
6
trait TrapDirectorTableGrouping
7
{
8
    
9
  
10
    /*************** Grouping ************/
11
    protected $grouppingActive=false;
12
    
13
    protected $groupingColumn='';
14
    
15
    protected $groupingVal='';
16
    
17
    protected $groupingColSpan=1;
18
      
19
    /*****************  Grouping ****************/
20
    
21
    public function setGrouping($columnDBName)
22
    {
23
        $this->groupingColumn = $columnDBName;
24
        $this->grouppingActive = TRUE;
25
    }
26
    
27
    public function initGrouping()
28
    {
29
        $this->groupingVal = '';
30
        $this->groupingColSpan = count($this->titles);
31
    }
32
    
33
    public function groupingPrintData( $value)
34
    {
35
        $html = "$value";
36
        return $html;
37
    }
38
    
39
    public function groupingNextLine( $values)
40
    {
41
        if ($this->grouppingActive === FALSE) return '';
42
        
43
        $dbcol = $this->groupingColumn;
44
        if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol )
45
        {
46
            $this->groupingVal = $values->$dbcol;
47
            $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>';
48
            return $html;
49
        }
50
        return '';
51
        
52
    }
53
    
54
  
55
}