Passed
Push — master ( 939775...4bbee1 )
by Christian
04:22
created

EntityManagerTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 3
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createQueryBuilder() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[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 Core23\DoctrineExtensions\Adapter\ORM;
13
14
use Doctrine\ORM\EntityManager;
15
use Doctrine\ORM\EntityRepository;
16
use Doctrine\ORM\QueryBuilder;
17
18
trait EntityManagerTrait
19
{
20
    /**
21
     * Creates a new QueryBuilder instance that is prepopulated for this entity name.
22
     *
23
     * @param string $alias
24
     * @param string $indexBy The index for the from
25
     *
26
     * @return QueryBuilder|EntityManager
27
     */
28
    final protected function createQueryBuilder(string $alias, string $indexBy = null)
29
    {
30
        return $this->getRepository()
31
            ->createQueryBuilder($alias, $indexBy);
32
    }
33
34
    /**
35
     * Returns the related Object Repository.
36
     *
37
     * @return EntityRepository
38
     */
39
    abstract protected function getRepository();
40
}
41