Completed
Push — 2.x ( 359f6e )
by Sullivan
14:45
created

QueryBuilder::expr()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sonata package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\DoctrineORMAdminBundle\Tests\Filter;
13
14
use Sonata\DoctrineORMAdminBundle\Filter\Filter;
15
16
class QueryBuilder
17
{
18
    public $parameters = array();
19
20
    public $query = array();
21
22
    /**
23
     * @param string $name
24
     * @param mixed  $value
25
     */
26
    public function setParameter($name, $value)
27
    {
28
        $this->parameters[$name] = $value;
29
    }
30
31
    /**
32
     * @param string $query
33
     */
34
    public function andWhere($query)
35
    {
36
        $this->query[] = $query;
37
    }
38
39
    /**
40
     * @return QueryBuilder
41
     */
42
    public function expr()
43
    {
44
        return $this;
45
    }
46
47
    /**
48
     * @param  string $name
49
     * @param  string $value
50
     * @return string
51
     */
52
    public function in($name, $value)
53
    {
54
        $this->query[] = 'in_'.$name;
55
56
        if (is_array($value)) {
57
            return sprintf('%s IN ("%s")', $name, implode(',', $value));
58
        }
59
60
        return sprintf('%s IN %s', 'in_'.$name, $value);
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getRootAlias()
67
    {
68
        return 'o';
69
    }
70
71
    /**
72
     * @param string $parameter
73
     * @param string $alias
74
     */
75
    public function leftJoin($parameter, $alias)
0 ignored issues
show
Unused Code introduced by
The parameter $alias is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
        $this->query[] = $parameter;
78
    }
79
}
80