Completed
Push — master ( 9d9484...761485 )
by Alexandre
01:59
created

ORMRepository::getQueryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace Black\Bridge\Doctrine\Common\Persistence;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
7
/**
8
 * Class ORMRepository
9
 */
10
class ORMRepository
11
{
12
    /**
13
     * @var
14
     */
15
    protected $manager;
16
17
    /**
18
     * @var
19
     */
20
    protected $class;
21
22
    /**
23
     * @param ObjectManager $manager
24
     * @param $class
25
     */
26
    public function __construct(ObjectManager $manager, $class)
27
    {
28
        $this->manager = $manager;
29
        $this->class = $class;
30
    }
31
32
     /**
33
     * @return mixed
34
     */
35
    public function getClassName()
36
    {
37
        return $this->class;
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43
    protected function getManager()
44
    {
45
        return $this->manager;
46
    }
47
48
    /**
49
     * @param string $alias
50
     * @param null $indexBy
51
     * @return \Doctrine\ORM\QueryBuilder
52
     */
53
    protected function getQueryBuilder($alias = 'p', $indexBy = null)
54
    {
55
        return $this->manager
56
            ->createQueryBuilder()
57
            ->select($alias)
58
            ->from($this->class, $alias, $indexBy);
59
    }
60
}
61