GroupBy   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addGroupBy() 0 9 2
A toString() 0 9 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder\Queries\Snippets;
6
7
use Puzzle\QueryBuilder\Snippet;
8
9
class GroupBy implements Snippet
10
{
11
    private
12
        $groupBy;
1 ignored issue
show
Coding Style introduced by
The visibility should be declared for property $groupBy.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
13
14 29
    public function __construct()
15
    {
16 29
        $this->groupBy = array();
17 29
    }
18
19 7
    public function addGroupBy(?string $column): self
20
    {
21 7
        if(!empty($column))
22
        {
23 5
            $this->groupBy[$column] = $column;
24
        }
25
26 7
        return $this;
27
    }
28
29 25
    public function toString(): string
30
    {
31 25
        if(empty($this->groupBy))
32
        {
33 20
            return '';
34
        }
35
36 5
        return sprintf('GROUP BY %s', implode(', ', $this->groupBy));
37
    }
38
}
39