GroupBy::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 3
nc 2
nop 2
1
<?php
2
3
/**
4
 * This file is part of the Happyr Doctrine Specification package.
5
 *
6
 * (c) Tobias Nyholm <[email protected]>
7
 *     Kacper Gunia <[email protected]>
8
 *     Peter Gribanov <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Happyr\DoctrineSpecification\Query;
15
16
use Doctrine\ORM\QueryBuilder;
17
use Happyr\DoctrineSpecification\Operand\Alias;
18
use Happyr\DoctrineSpecification\Operand\Field;
19
20
class GroupBy implements QueryModifier
21
{
22
    /**
23
     * @deprecated This property will be marked as private in 2.0.
24
     *
25
     * @var Field|Alias
26
     */
27
    protected $field;
28
29
    /**
30
     * @deprecated This property will be marked as private in 2.0.
31
     *
32
     * @var string|null
33
     */
34
    protected $dqlAlias;
35
36
    /**
37
     * @param Field|Alias|string $field
38
     * @param string|null        $dqlAlias
39
     */
40 View Code Duplication
    public function __construct($field, $dqlAlias = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        if (!($field instanceof Field) && !($field instanceof Alias)) {
43
            $field = new Field($field);
44
        }
45
46
        $this->field = $field;
0 ignored issues
show
Deprecated Code introduced by
The property Happyr\DoctrineSpecification\Query\GroupBy::$field has been deprecated with message: This property will be marked as private in 2.0.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
47
        $this->dqlAlias = $dqlAlias;
0 ignored issues
show
Deprecated Code introduced by
The property Happyr\DoctrineSpecifica...uery\GroupBy::$dqlAlias has been deprecated with message: This property will be marked as private in 2.0.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
48
    }
49
50
    /**
51
     * @param QueryBuilder $qb
52
     * @param string       $dqlAlias
53
     */
54
    public function modify(QueryBuilder $qb, $dqlAlias)
55
    {
56
        if (null !== $this->dqlAlias) {
0 ignored issues
show
Deprecated Code introduced by
The property Happyr\DoctrineSpecifica...uery\GroupBy::$dqlAlias has been deprecated with message: This property will be marked as private in 2.0.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
57
            $dqlAlias = $this->dqlAlias;
0 ignored issues
show
Deprecated Code introduced by
The property Happyr\DoctrineSpecifica...uery\GroupBy::$dqlAlias has been deprecated with message: This property will be marked as private in 2.0.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
58
        }
59
60
        $qb->addGroupBy($this->field->transform($qb, $dqlAlias));
0 ignored issues
show
Deprecated Code introduced by
The property Happyr\DoctrineSpecification\Query\GroupBy::$field has been deprecated with message: This property will be marked as private in 2.0.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
61
    }
62
}
63