Completed
Pull Request — master (#105)
by
unknown
03:48
created

NotQuery::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
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;
13
14
use ONGR\ElasticsearchDSL\BuilderInterface;
15
16
/**
17
 * Represents Elasticsearch "not" query.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-query.html
20
 */
21
class NotQuery implements BuilderInterface
22
{
23
    /**
24
     * @var array
25
     */
26
    private $query;
27
28
    /**
29
     * @param BuilderInterface $query
30
     */
31
    public function __construct(BuilderInterface $query)
32
    {
33
        $this->query = $query;
0 ignored issues
show
Documentation Bug introduced by
It seems like $query of type object<ONGR\ElasticsearchDSL\BuilderInterface> is incompatible with the declared type array of property $query.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getType()
40
    {
41
        return 'not';
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function toArray()
48
    {
49
        $output = [$this->getType() => $this->query->toArray()];
0 ignored issues
show
Bug introduced by
The method toArray cannot be called on $this->query (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
50
51
        return $output;
52
    }
53
}
54