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

Elasticsearch::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
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