Client   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A reindex() 0 2 1
A getConnection() 0 8 1
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 24/3/2561
7
 * Time: 19:58 น.
8
 */
9
10
namespace Suilven\ManticoreSearch\Service;
11
12
use SilverStripe\Core\Config\Config;
13
14
class Client
15
{
16
    /**
17
     * Get a connection to sphinx using the values configured in YML files for port and host
18
     *
19
     * @return \Manticoresearch\Client Client object for accessing Manticore
20
     */
21
    public function getConnection(): \Manticoresearch\Client
22
    {
23
        $host = Config::inst()->get('Suilven\ManticoreSearch\Service\Client', 'host');
24
        $port = Config::inst()->get('Suilven\ManticoreSearch\Service\Client', 'port');
25
26
        $config = ['host'=>$host, 'port'=>$port];
27
28
        return new \Manticoresearch\Client($config);
29
    }
30
31
32
    /**
33
     * Execute reindex command. @todo Can this be done using SphinxQL?
34
     */
35
    public function reindex(): void
36
    {
37
        // @todo
38
    }
39
}
40