Passed
Push — master ( c293a9...361f10 )
by Gordon
10:37 queued 08:38
created

Indexer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A index() 0 11 2
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 24/3/2561
7
 * Time: 21:14 น.
8
 */
9
10
namespace Suilven\ManticoreSearch\Service;
11
12
class Indexer extends \Suilven\FreeTextSearch\Base\Indexer
13
{
14
    public function index(\SilverStripe\ORM\DataObject $dataObject): void
15
    {
16
        $payload = $this->getFieldsToIndex($dataObject);
17
        $coreClient = new Client();
18
        $client = $coreClient->getConnection();
19
20
        $indexNames = \array_keys($payload);
21
        foreach ($indexNames as $indexName) {
22
            $indexPayload = $payload[$indexName];
23
            $manticoreIndex = new \Manticoresearch\Index($client, $indexName);
24
            $manticoreIndex->replaceDocument($indexPayload, $dataObject->ID);
25
        }
26
    }
27
}
28