Drop::setBody()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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