Set::setBody()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 4
eloc 6
c 2
b 0
f 1
nc 2
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
4
namespace Manticoresearch\Endpoints\Nodes;
5
6
use Manticoresearch\Endpoints\EmulateBySql;
7
use Manticoresearch\Exceptions\RuntimeException;
8
9
class Set extends EmulateBySql
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $index;
15
16
    public function setBody($params = null)
17
    {
18
        $this->body = $params;
19
        if (isset($params['variable']) && is_array($params['variable'])) {
20
            return parent::setBody([
21
                'query' =>  "SET " . (isset($params['type']) ?  $params['type'] . "'" : "")." ".
22
                    $params['variable']['name']."=" . $params['variable']['value']
23
            ]);
24
        }
25
        throw new RuntimeException('Variable is missing for /nodes/set');
26
    }
27
}
28