ExistsQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getType() 0 4 1
A toArray() 0 8 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\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