GroupBy::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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