Completed
Pull Request — master (#348)
by
unknown
10:14
created

FuzzyQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 50
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ONGR\ElasticsearchDSL\Query\TermLevel;
4
5
use ONGR\ElasticsearchDSL\BuilderInterface;
6
use ONGR\ElasticsearchDSL\ParametersTrait;
7
8
/**
9
 * Represents Elasticsearch "fuzzy" query.
10
 *
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
12
 */
13
class FuzzyQuery implements BuilderInterface
14
{
15
    use ParametersTrait;
16
17
    public function __construct(
18
        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...
19
        private string $value,
20
        array $parameters = []
21
    ) {
22
        $this->setParameters($parameters);
23
    }
24
25
    public function getType(): string
26
    {
27
        return 'fuzzy';
28
    }
29
30
    public function toArray(): array
31
    {
32
        $query = [
33
            'value' => $this->value,
34
        ];
35
36
        $output = [
37
            $this->field => $this->processArray($query),
38
        ];
39
40
        return [$this->getType() => $output];
41
    }
42
}
43