Completed
Pull Request — master (#103)
by
unknown
04:42
created

TemplateQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getType() 0 4 1
A toArray() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\ElasticsearchDSL\Query;
13
14
use ONGR\ElasticsearchDSL\BuilderInterface;
15
16
/**
17
 * Represents Elasticsearch "template" query.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-template-query.html
20
 */
21
class TemplateQuery implements BuilderInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private $inline;
27
28
    /**
29
     * @var array
30
     */
31
    private $params;
32
33
    /**
34
     * @param string $inline A template of the query
35
     * @param array  $params Parameters to insert into template
36
     */
37
    public function __construct($inline, array $params)
38
    {
39
        $this->inline = $inline;
40
        $this->params = $params;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getType()
47
    {
48
        return 'template';
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function toArray()
55
    {
56
        $output = [
57
            'inline' => $this->inline,
58
            'params' => $this->params,
59
        ];
60
61
        return [$this->getType() => $output];
62
    }
63
}
64