GroupBy::addGroupBy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Muffin\Queries\Snippets;
4
5
use Muffin\Snippet;
6
7
class GroupBy implements Snippet
8
{
9
    private
10
        $groupBy;
11
12 29
    public function __construct()
13
    {
14 29
        $this->groupBy = array();
15 29
    }
16
17 7
    public function addGroupBy($column)
18
    {
19 7
        if(!empty($column))
20 7
        {
21 5
            $this->groupBy[$column] = $column;
22 5
        }
23
24 7
        return $this;
25
    }
26
27 25
    public function toString()
28
    {
29 25
        if(empty($this->groupBy))
30 25
        {
31 20
            return '';
32
        }
33
34 5
        return sprintf('GROUP BY %s', implode(', ', $this->groupBy));
35
    }
36
}
37