Cluster::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Manticoresearch;
5
6
use Manticoresearch\Endpoints\Cluster\Alter;
7
use Manticoresearch\Endpoints\Cluster\Create;
8
use Manticoresearch\Endpoints\Cluster\Delete;
9
use Manticoresearch\Endpoints\Cluster\Join;
10
use Manticoresearch\Endpoints\Cluster\Set;
11
use Manticoresearch\Response\SqlToArray;
12
13
class Cluster
14
{
15
    /**
16
     * @var Client
17
     */
18
    protected $client;
19
    protected $params = ['responseClass' => SqlToArray::class];
20
21
    /**
22
     * Pq constructor.
23
     * @param Client $client
24
     */
25
    public function __construct($client)
26
    {
27
        $this->client = $client;
28
    }
29
30
    public function alter($params)
31
    {
32
        $cluster = $params['cluster'] ?? null;
33
        $body = $params['body'];
34
        $endpoint = new Alter();
35
        $endpoint->setCluster($cluster);
36
        $endpoint->setBody($body);
37
        $response = $this->client->request(
38
            $endpoint,
39
            array_merge($this->params, ['responseClassParams' => ['customMapping' => true]])
40
        );
41
        return  $response->getResponse();
42
    }
43
44
    public function create($params)
45
    {
46
        $cluster = $params['cluster'] ?? null;
47
        $body = $params['body'];
48
        $endpoint = new Create();
49
        $endpoint->setCluster($cluster);
50
        $endpoint->setBody($body);
51
        $response = $this->client->request($endpoint, $this->params);
52
        return  $response->getResponse();
53
    }
54
55
    public function delete($params)
56
    {
57
        $cluster = $params['cluster'] ?? null;
58
        $body = $params['body'];
59
        $endpoint = new Delete();
60
        $endpoint->setCluster($cluster);
61
        $endpoint->setBody($body);
62
        $response = $this->client->request($endpoint, $this->params);
63
        return  $response->getResponse();
64
    }
65
66
    public function join($params)
67
    {
68
        $cluster = $params['cluster'] ?? null;
69
        $body = $params['body'];
70
        $endpoint = new Join();
71
        $endpoint->setCluster($cluster);
72
        $endpoint->setBody($body);
73
        $response = $this->client->request($endpoint, $this->params);
74
        return  $response->getResponse();
75
    }
76
77
    public function set($params)
78
    {
79
        $cluster = $params['cluster'] ?? null;
80
        $body = $params['body'];
81
        $endpoint = new Set();
82
        $endpoint->setCluster($cluster);
83
        $endpoint->setBody($body);
84
        $response = $this->client->request($endpoint, $this->params);
85
        return  $response->getResponse();
86
    }
87
}
88