Completed
Push — master ( 076de6...2259f6 )
by Simonas
06:47 queued 04:16
created

src/Query/MissingQuery.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
use ONGR\ElasticsearchDSL\ParametersTrait;
16
17
/**
18
 * Represents Elasticsearch "missing" query.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-query.html
21
 */
22 View Code Duplication
class MissingQuery implements BuilderInterface
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $field;
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param string $field      Field name
35
     * @param array  $parameters Optional parameters
36
     */
37
    public function __construct($field, array $parameters = [])
38
    {
39
        $this->field = $field;
40
        $this->setParameters($parameters);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getType()
47
    {
48
        return 'missing';
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function toArray()
55
    {
56
        $query = ['field' => $this->field];
57
        $output = $this->processArray($query);
58
59
        return [$this->getType() => $output];
60
    }
61
}
62