Completed
Push — 1.x ( 747b4c...b6bf38 )
by Adrian
04:52 queued 11s
created

ExplainQuery::setBody()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 3
eloc 5
c 2
b 0
f 1
nc 3
nop 1
dl 0
loc 9
rs 10
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
                return parent::setBody(['query' => "EXPLAIN QUERY ".$this->index. '\''.$params['query'].'\'']);
22
            }
23
            throw new RuntimeException('Query param is missing.');
24
        }
25
        throw new RuntimeException('Index name is missing.');
26
    }
27
    /**
28
     * @return mixed
29
     */
30
    public function getIndex()
31
    {
32
        return $this->index;
33
    }
34
35
    /**
36
     * @param mixed $index
37
     */
38
    public function setIndex($index)
39
    {
40
        $this->index = $index;
41
    }
42
}
43