Completed
Push — master ( 6c9334...f3ba17 )
by Simonas
02:26
created

ExistsQuery::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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\TermLevel;
13
14
use ONGR\ElasticsearchDSL\BuilderInterface;
15
16
/**
17
 * Represents Elasticsearch "exists" query.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html
20
 */
21
class ExistsQuery implements BuilderInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private $field;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param string $field Field value
32
     */
33
    public function __construct($field)
34
    {
35
        $this->field = $field;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getType()
42
    {
43
        return 'exists';
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function toArray()
50
    {
51
        return [
52
            $this->getType() => [
53
                'field' => $this->field,
54
            ],
55
        ];
56
    }
57
}
58