Completed
Push — master ( 340011...d942bb )
by Mads
8s
created

GroupByCriterion   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A apply() 0 4 1
1
<?php
2
3
namespace Napp\Core\Dbal\Criteria;
4
5
use Illuminate\Support\Arr;
6
7
class GroupByCriterion implements CriterionInterface
8
{
9
    private $groups;
10
11
    public function __construct(...$groups)
12
    {
13
        foreach ($groups as $group) {
14
            $this->groups = array_merge(
15
                (array) $this->groups,
16
                Arr::wrap($group)
17
            );
18
        }
19
    }
20
21
    /**
22
     * @param \Illuminate\Database\Eloquent\Builder $query
23
     * @return \Illuminate\Database\Eloquent\Builder|void
24
     */
25
    public function apply($query)
26
    {
27
        $query->getQuery()->groupBy($this->groups);
28
    }
29
}
30