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

ExplainQuery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

3 Methods

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