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

IdsQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 41
loc 41
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 "ids" query.
10
 *
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
12
 */
13
class IdsQuery implements BuilderInterface
14
{
15
    use ParametersTrait;
16
17
    public function __construct(private array $values, array $parameters = [])
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...
18
    {
19
        $this->setParameters($parameters);
20
    }
21
22
    public function getType(): string
23
    {
24
        return 'ids';
25
    }
26
27
    public function toArray(): array
28
    {
29
        $query = [
30
            'values' => $this->values,
31
        ];
32
33
        $output = $this->processArray($query);
34
35
        return [$this->getType() => $output];
36
    }
37
}
38