Completed
Push — master ( 68be21...073c54 )
by Kévin
02:41
created

DoctrineORM   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 44
wmc 4
lcom 1
cbo 4
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A createCompilationContext() 0 11 1
A createVisitor() 0 4 1
A getExecutorTraits() 0 7 1
1
<?php
2
3
namespace RulerZ\Target\DoctrineORM;
4
5
use Doctrine\ORM\QueryBuilder;
6
7
use RulerZ\Compiler\Context;
8
use RulerZ\Target\AbstractSqlTarget;
9
10
class DoctrineORM extends AbstractSqlTarget
11
{
12
    /**
13
     * @inheritDoc
14
     */
15
    public function supports($target, $mode)
16
    {
17
        return $target instanceof QueryBuilder;
18
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23
    public function createCompilationContext($target)
24
    {
25
        /** @var \Doctrine\ORM\QueryBuilder $target */
26
27
        return new Context([
28
            'root_aliases' => $target->getRootAliases(),
29
            'root_entities' => $target->getRootEntities(),
30
            'em' => $target->getEntityManager(),
31
            'joins' => $target->getDQLPart('join'),
32
        ]);
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    protected function createVisitor(Context $context)
39
    {
40
        return new DoctrineORMVisitor($context, $this->getOperators(), $this->allowStarOperator);
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    protected function getExecutorTraits()
47
    {
48
        return [
49
            '\RulerZ\Executor\DoctrineORM\FilterTrait',
50
            '\RulerZ\Executor\Polyfill\FilterBasedSatisfaction',
51
        ];
52
    }
53
}
54