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

SpanNotQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 47
loc 47
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
/*
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 not query.
20
 *
21
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
22
 */
23
class SpanNotQuery implements SpanQueryInterface
24
{
25
    use ParametersTrait;
26
27
    public function __construct(
28
        private SpanQueryInterface $include,
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 $exclude,
30
        array $parameters = []
31
    ) {
32
        $this->setParameters($parameters);
33
    }
34
35
    public function getType(): string
36
    {
37
        return 'span_not';
38
    }
39
40
    public function toArray(): array
41
    {
42
        $query = [
43
            'include' => $this->include->toArray(),
44
            'exclude' => $this->exclude->toArray(),
45
        ];
46
47
        return [$this->getType() => $this->processArray($query)];
48
    }
49
}
50