FieldMaskingSpanQuery   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getQuery() 0 4 1
A setQuery() 0 6 1
A getField() 0 4 1
A setField() 0 6 1
A toArray() 0 11 1
A getType() 0 4 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\Span;
13
14
use ONGR\ElasticsearchDSL\ParametersTrait;
15
16
/**
17
 * Elasticsearch span within query.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-field-masking-query.html
20
 */
21
class FieldMaskingSpanQuery implements SpanQueryInterface
22
{
23
    use ParametersTrait;
24
25
    /**
26
     * @var SpanQueryInterface
27
     */
28
    private $query;
29
30
    /**
31
     * @var string
32
     */
33
    private $field;
34
35
    /**
36
     * @param string             $field
37
     * @param SpanQueryInterface $query
38
     */
39
    public function __construct($field, SpanQueryInterface $query)
40
    {
41
        $this->setQuery($query);
42
        $this->setField($field);
43
    }
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getQuery()
49
    {
50
        return $this->query;
51
    }
52
53
    /**
54
     * @param mixed $query
55
     *
56
     * @return $this
57
     */
58
    public function setQuery($query)
59
    {
60
        $this->query = $query;
61
62
        return $this;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getField()
69
    {
70
        return $this->field;
71
    }
72
73
    /**
74
     * @param string $field
75
     *
76
     * @return $this
77
     */
78
    public function setField($field)
79
    {
80
        $this->field = $field;
81
82
        return $this;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function toArray()
89
    {
90
        $output = [
91
            'query' => $this->getQuery()->toArray(),
92
            'field' => $this->getField(),
93
        ];
94
95
        $output = $this->processArray($output);
96
97
        return [$this->getType() => $output];
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function getType()
104
    {
105
        return 'field_masking_span';
106
    }
107
}
108