Completed
Push — master ( b25384...a9cbe2 )
by Adrian
01:51
created

ExplainQuery::setIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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