Optimize::setIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Manticoresearch\Endpoints\Indices;
5
6
use Manticoresearch\Endpoints\EmulateBySql;
7
use Manticoresearch\Exceptions\RuntimeException;
8
use Manticoresearch\Utils;
9
10
/**
11
 * Class Optimize
12
 * @package Manticoresearch\Endpoints\Indices
13
 */
14
class Optimize extends EmulateBySql
15
{
16
    use Utils;
17
    /**
18
     * @var string
19
     */
20
    protected $index;
21
22
    public function setBody($params = null)
23
    {
24
        if (isset($this->index)) {
25
            return parent::setBody(['query' => "OPTIMIZE INDEX ".$this->index. "".
26
                (isset($params['sync'])?" OPTION sync='".$params['sync']."'":"")]);
27
        }
28
        throw new RuntimeException('Index name is missing.');
29
    }
30
    /**
31
     * @return mixed
32
     */
33
    public function getIndex()
34
    {
35
        return $this->index;
36
    }
37
38
    /**
39
     * @param mixed $index
40
     */
41
    public function setIndex($index)
42
    {
43
        $this->index = $index;
44
    }
45
}
46