Set   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCLuster() 0 3 1
A setBody() 0 10 3
A setCluster() 0 3 1
1
<?php
2
3
4
namespace Manticoresearch\Endpoints\Cluster;
5
6
use Manticoresearch\Endpoints\EmulateBySql;
7
use Manticoresearch\Endpoints\Sql;
8
use Manticoresearch\Exceptions\RuntimeException;
9
use Manticoresearch\Utils;
10
11
class Set extends EmulateBySql
12
{
13
    use Utils;
14
    /**
15
     * @var string
16
     */
17
    protected $cluster;
18
19
    public function setBody($params = null)
20
    {
21
        if (isset($params['variable'])) {
22
            return parent::setBody([
23
                'query' => "SET CLUSTER" . $this->cluster . " GLOBAL '" . $params['variable']['name'], "'=" .
24
                (is_numeric($params['variable']['value']) ?
25
                    $params['variable']['value'] : "'" . $params['variable']['value'] . "'")
26
            ]);
27
        }
28
        throw new RuntimeException('Variable is missing for /cluster/set');
29
    }
30
31
    /**
32
     * @return mixed
33
     */
34
    public function getCLuster()
35
    {
36
        return $this->cluster;
37
    }
38
39
    /**
40
     * @param mixed $cluster
41
     */
42
    public function setCluster($cluster)
43
    {
44
        $this->cluster = $cluster;
45
    }
46
}
47