Optimize   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndex() 0 3 1
A setIndex() 0 3 1
A setBody() 0 7 3
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