Completed
Push — master ( 53b35c...4f4192 )
by Peter
06:07
created

Field::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Happyr\DoctrineSpecification\Operand;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Happyr\DoctrineSpecification\Query\Selection\Selection;
7
8
class Field implements Operand, Selection
9
{
10
    /**
11
     * @var string
12
     */
13
    private $fieldName = '';
14
15
    /**
16
     * @param string $fieldName
17
     */
18
    public function __construct($fieldName)
19
    {
20
        $this->fieldName = $fieldName;
21
    }
22
23
    /**
24
     * @param QueryBuilder $qb
25
     * @param string       $dqlAlias
26
     *
27
     * @return string
28
     */
29
    public function transform(QueryBuilder $qb, $dqlAlias)
30
    {
31
        return sprintf('%s.%s', $dqlAlias, $this->fieldName);
32
    }
33
}
34