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

Elasticsearch   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 37
wmc 4
lcom 0
cbo 3
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 4 1
A createVisitor() 0 4 1
A getExecutorTraits() 0 7 1
A getOperators() 0 4 1
1
<?php
2
3
namespace RulerZ\Target\Elasticsearch;
4
5
use Elasticsearch\Client;
6
7
use RulerZ\Compiler\Context;
8
use RulerZ\Target\AbstractCompilationTarget;
9
use RulerZ\Target\GenericElasticsearchVisitor;
10
use RulerZ\Target\Operators\GenericElasticsearchDefinitions;
11
12
class Elasticsearch extends AbstractCompilationTarget
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function supports($target, $mode)
18
    {
19
        return $target instanceof Client;
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    protected function createVisitor(Context $context)
26
    {
27
        return new GenericElasticsearchVisitor($this->getOperators());
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    protected function getExecutorTraits()
34
    {
35
        return [
36
            '\RulerZ\Executor\Elasticsearch\ElasticsearchFilterTrait',
37
            '\RulerZ\Executor\Polyfill\FilterBasedSatisfaction',
38
        ];
39
    }
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function getOperators()
45
    {
46
        return GenericElasticsearchDefinitions::create(parent::getOperators());
47
    }
48
}
49