SpanNearQuery   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSlop() 0 4 1
A setSlop() 0 6 1
A getType() 0 4 1
A toArray() 0 11 2
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\Span;
13
14
/**
15
 * Elasticsearch span near query.
16
 *
17
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html
18
 */
19
class SpanNearQuery extends SpanOrQuery implements SpanQueryInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    private $slop;
25
26
    /**
27
     * @return int
28
     */
29
    public function getSlop()
30
    {
31
        return $this->slop;
32
    }
33
34
    /**
35
     * @param int $slop
36
     *
37
     * @return $this
38
     */
39
    public function setSlop($slop)
40
    {
41
        $this->slop = $slop;
42
43
        return $this;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getType()
50
    {
51
        return 'span_near';
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function toArray()
58
    {
59
        $query = [];
60
        foreach ($this->getQueries() as $type) {
61
            $query['clauses'][] = $type->toArray();
62
        }
63
        $query['slop'] = $this->getSlop();
64
        $output = $this->processArray($query);
65
66
        return [$this->getType() => $output];
67
    }
68
}
69