ElasticSearchWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 81.08 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 30
loc 37
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 16 16 2
A writeOne() 14 14 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
 * @author Jean Silva <[email protected]>
4
 * @license MIT
5
 */
6
namespace Jeancsil\FlightSpy\Service\ElasticSearch;
7
8
class ElasticSearchWriter extends ResultWriter
9
{
10
    use ElasticSearchProcessorTrait;
11
    use ConfiguratorTrait;
12
13 View Code Duplication
    public function write(array $document)
0 ignored issues
show
Duplication introduced by
This method 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...
14
    {
15
        $documents = $this
16
            ->getProcessor()
17
            ->process($document);
18
19
        foreach ($documents as $document) {
20
            $params = [
21
                'index' => $this->indexName,
22
                'type' => $this->typeName,
23
                'body' => $document
24
            ];
25
26
            Client::getInstance()->index($params);
27
        }
28
    }
29
30 View Code Duplication
    public function writeOne(array $document)
0 ignored issues
show
Duplication introduced by
This method 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...
31
    {
32
        $doc = $this
33
            ->getProcessor()
34
            ->process($document);
35
36
        $params = [
37
            'index' => $this->indexName,
38
            'type' => $this->typeName,
39
            'body' => $doc
40
        ];
41
42
        Client::getInstance()->index($params);
43
    }
44
}
45