Completed
Push — master ( 2fc32e...766668 )
by Mantas
08:17
created

FilterEndpoint::getBoolInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
nc 1
cc 1
eloc 2
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\SearchEndpoint;
13
14
use ONGR\ElasticsearchDSL\Query\FilteredQuery;
15
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
16
17
/**
18
 * Search filter dsl endpoint.
19
 */
20
class FilterEndpoint extends QueryEndpoint
21
{
22
    /**
23
     * Endpoint name
24
     */
25
    const NAME = 'filter';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
31
    {
32
        if (!$this->getBool()) {
33
            return null;
34
        }
35
36
        $query = new FilteredQuery();
0 ignored issues
show
Deprecated Code introduced by
The class ONGR\ElasticsearchDSL\Query\FilteredQuery has been deprecated with message: Will be removed in 2.0. Use the `bool` query instead with a `filter` clause.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
37
        $query->setFilter($this->getBool());
38
39
        $this->addReference('filtered_query', $query);
0 ignored issues
show
Documentation introduced by
$query is of type object<ONGR\ElasticsearchDSL\Query\FilteredQuery>, but the function expects a array|string|object<stdClass>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function getOrder()
46
    {
47
        return 1;
48
    }
49
}
50