Completed
Pull Request — master (#348)
by
unknown
01:15
created

FieldMaskingSpanQuery   A

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
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
declare(strict_types=1);
13
14
namespace ONGR\ElasticsearchDSL\Query\Span;
15
16
use ONGR\ElasticsearchDSL\ParametersTrait;
17
18
/**
19
 * Elasticsearch span within query.
20
 *
21
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-field-masking-query.html
22
 */
23
class FieldMaskingSpanQuery implements SpanQueryInterface
24
{
25
    use ParametersTrait;
26
27
    public function __construct(
28
        private string $field,
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_PRIVATE, expecting T_VARIABLE
Loading history...
29
        private SpanQueryInterface $query
30
    ) {
31
        $this->setQuery($query);
32
        $this->setField($field);
33
    }
34
35
    public function getQuery(): SpanQueryInterface
36
    {
37
        return $this->query;
38
    }
39
40
    public function setQuery(SpanQueryInterface $query): static
41
    {
42
        $this->query = $query;
43
44
        return $this;
45
    }
46
47
    public function getField(): string
48
    {
49
        return $this->field;
50
    }
51
52
    public function setField(string $field): static
53
    {
54
        $this->field = $field;
55
56
        return $this;
57
    }
58
59
    public function toArray(): array
60
    {
61
        $output = [
62
            'query' => $this->getQuery()->toArray(),
63
            'field' => $this->getField(),
64
        ];
65
66
        $output = $this->processArray($output);
67
68
        return [$this->getType() => $output];
69
    }
70
71
    public function getType(): string
72
    {
73
        return 'field_masking_span';
74
    }
75
}
76