ElasticSearchWriter::writeOne()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 14
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 2
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