Completed
Push — master ( 9552d6...4b2b1b )
by Simonas
08:12
created

FieldMaskingSpanQuery   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 83
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 5 1
A getField() 0 4 1
A setField() 0 5 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
     * @return self
56
     */
57
    public function setQuery($query)
58
    {
59
        $this->query = $query;
60
        return $this;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function getField()
67
    {
68
        return $this->field;
69
    }
70
71
    /**
72
     * @param string $field
73
     * @return FieldMaskingSpanQuery
74
     */
75
    public function setField($field)
76
    {
77
        $this->field = $field;
78
        return $this;
79
    }
80
81
    /**
82
     * {@inheritdoc}
83
     */
84
    public function toArray()
85
    {
86
        $output = [
87
            'query' => $this->getQuery()->toArray(),
88
            'field' => $this->getField(),
89
        ];
90
91
        $output = $this->processArray($output);
92
93
        return [$this->getType() => $output];
94
    }
95
96
    /**
97
     * {@inheritdoc}
98
     */
99
    public function getType()
100
    {
101
        return 'field_masking_span';
102
    }
103
}
104