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

ExplainQuery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

3 Methods

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