SpanNotQuery   A
last analyzed

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getType() 4 4 1
A toArray() 9 9 1

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
namespace ONGR\ElasticsearchDSL\Query\Span;
13
14
use ONGR\ElasticsearchDSL\ParametersTrait;
15
16
/**
17
 * Elasticsearch Span not query.
18
 *
19
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
20
 */
21 View Code Duplication
class SpanNotQuery implements SpanQueryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    use ParametersTrait;
24
25
    /**
26
     * @var SpanQueryInterface
27
     */
28
    private $include;
29
30
    /**
31
     * @var SpanQueryInterface
32
     */
33
    private $exclude;
34
35
    /**
36
     * @param SpanQueryInterface $include
37
     * @param SpanQueryInterface $exclude
38
     * @param array              $parameters
39
     */
40
    public function __construct(SpanQueryInterface $include, SpanQueryInterface $exclude, array $parameters = [])
41
    {
42
        $this->include = $include;
43
        $this->exclude = $exclude;
44
        $this->setParameters($parameters);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getType()
51
    {
52
        return 'span_not';
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function toArray()
59
    {
60
        $query = [
61
            'include' => $this->include->toArray(),
62
            'exclude' => $this->exclude->toArray(),
63
        ];
64
65
        return [$this->getType() => $this->processArray($query)];
66
    }
67
}
68