Import   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndex() 0 3 1
A setBody() 0 14 3
A setIndex() 0 3 1
1
<?php
2
3
4
namespace Manticoresearch\Endpoints\Indices;
5
6
use Manticoresearch\Endpoints\EmulateBySql;
7
use Manticoresearch\Exceptions\RuntimeException;
8
9
class Import extends EmulateBySql
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $index;
15
16
    public function setBody($params = null)
17
    {
18
        if (isset($this->index)) {
19
            if (isset($params['path'])) {
20
                return parent::setBody([
21
                    'query' => 'IMPORT TABLE ' .
22
                        $this->index .
23
                        ' FROM ' .
24
                        $params['path']
25
                ]);
26
            }
27
            throw new RuntimeException('Missing import index path in /indices/import');
28
        }
29
        throw new RuntimeException('Missing index name in /indices/import');
30
    }
31
32
    /**
33
     * @return mixed
34
     */
35
    public function getIndex()
36
    {
37
        return $this->index;
38
    }
39
40
    /**
41
     * @param mixed $index
42
     */
43
    public function setIndex($index)
44
    {
45
        $this->index = $index;
46
    }
47
}
48