@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | public $retries; |
27 | 27 | |
28 | - public $retries_attempts =0; |
|
28 | + public $retries_attempts = 0; |
|
29 | 29 | |
30 | 30 | public function __construct(array $connections, SelectorInterface $strategy, int $retries) |
31 | 31 | { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | public function getConnection(): Connection |
53 | 53 | { |
54 | 54 | $this->retries_attempts++; |
55 | - $connection = $this->strategy->getConnection($this->_connections); |
|
55 | + $connection = $this->strategy->getConnection($this->_connections); |
|
56 | 56 | if ($connection->isAlive()) { |
57 | 57 | return $connection; |
58 | 58 | } |
@@ -30,9 +30,9 @@ |
||
30 | 30 | */ |
31 | 31 | protected $_content_type; |
32 | 32 | |
33 | - public function __construct($params=[]) |
|
33 | + public function __construct($params = []) |
|
34 | 34 | { |
35 | - if (count($params)>0) { |
|
35 | + if (count($params) > 0) { |
|
36 | 36 | $this->setBody($params['body'] ?? []); |
37 | 37 | $this->setQuery($params['query'] ?? []); |
38 | 38 | $this->setContentType($params['content_type'] ?? 'application/json'); |
@@ -237,7 +237,7 @@ |
||
237 | 237 | ] |
238 | 238 | ]; |
239 | 239 | |
240 | - }elseif($operation==='drop'){ |
|
240 | + } elseif($operation==='drop'){ |
|
241 | 241 | $params = [ |
242 | 242 | 'index' => $this->_index, |
243 | 243 | 'body' => [ |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function deleteDocuments($query) |
89 | 89 | { |
90 | - if($query instanceof Query) { |
|
90 | + if ($query instanceof Query) { |
|
91 | 91 | $query = $query->toArray(); |
92 | 92 | } |
93 | 93 | $params = [ |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | public function updateDocuments($data, $query) |
115 | 115 | { |
116 | - if($query instanceof Query) { |
|
116 | + if ($query instanceof Query) { |
|
117 | 117 | $query = $query->toArray(); |
118 | 118 | } |
119 | 119 | $params = [ |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | return $this->_client->bulk(['body' => $toreplace]); |
156 | 156 | } |
157 | 157 | |
158 | - public function create($fields, $settings = [],$silent=false) |
|
158 | + public function create($fields, $settings = [], $silent = false) |
|
159 | 159 | { |
160 | 160 | $params = [ |
161 | 161 | 'index' => $this->_index, |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | 'settings' => $settings |
165 | 165 | ] |
166 | 166 | ]; |
167 | - if($silent===true) { |
|
167 | + if ($silent === true) { |
|
168 | 168 | $params['body']['silent'] = true; |
169 | 169 | } |
170 | 170 | return $this->_client->indices()->create($params); |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | $this->_client->indices()->flushramchunk($params); |
233 | 233 | } |
234 | 234 | |
235 | - public function alter($operation,$name, $type = null) |
|
235 | + public function alter($operation, $name, $type = null) |
|
236 | 236 | { |
237 | - if($operation==='add') { |
|
237 | + if ($operation === 'add') { |
|
238 | 238 | $params = [ |
239 | 239 | 'index' => $this->_index, |
240 | 240 | 'body' => [ |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | ] |
244 | 244 | ]; |
245 | 245 | |
246 | - }elseif($operation==='drop'){ |
|
246 | + }elseif ($operation === 'drop') { |
|
247 | 247 | $params = [ |
248 | 248 | 'index' => $this->_index, |
249 | 249 | 'body' => [ |
@@ -18,8 +18,8 @@ |
||
18 | 18 | $this->_body = $params; |
19 | 19 | if (isset($params['variable']) && is_array($params['variable'])) { |
20 | 20 | return parent::setBody([ |
21 | - 'query' => "SET " . (isset($params['type']) ? $params['type'] . "'" : "")." ". |
|
22 | - $params['variable']['name']."=" . $params['variable']['value'] |
|
21 | + 'query' => "SET " . (isset($params['type']) ? $params['type'] . "'" : "") . " " . |
|
22 | + $params['variable']['name'] . "=" . $params['variable']['value'] |
|
23 | 23 | ]); |
24 | 24 | |
25 | 25 | } |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | public function __construct($client) |
39 | 39 | { |
40 | 40 | $this->_client = $client; |
41 | - $this->_params =['responseClass'=>'Manticoresearch\\Response\\SqlToArray']; |
|
41 | + $this->_params = ['responseClass'=>'Manticoresearch\\Response\\SqlToArray']; |
|
42 | 42 | } |
43 | 43 | |
44 | - public function agentstatus($params=[]) |
|
44 | + public function agentstatus($params = []) |
|
45 | 45 | { |
46 | 46 | $body = $params['body']??[]; |
47 | 47 | $endpoint = new AgentStatus(); |
48 | 48 | $endpoint->setBody($body); |
49 | - $response = $this->_client->request($endpoint,$this->_params); |
|
49 | + $response = $this->_client->request($endpoint, $this->_params); |
|
50 | 50 | return $response->getResponse(); |
51 | 51 | } |
52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $body = $params['body']; |
56 | 56 | $endpoint = new CreateFunction(); |
57 | 57 | $endpoint->setBody($body); |
58 | - $response = $this->_client->request($endpoint,$this->_params); |
|
58 | + $response = $this->_client->request($endpoint, $this->_params); |
|
59 | 59 | return $response->getResponse(); |
60 | 60 | } |
61 | 61 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $body = $params['body']; |
65 | 65 | $endpoint = new CreatePlugin(); |
66 | 66 | $endpoint->setBody($body); |
67 | - $response = $this->_client->request($endpoint,$this->_params); |
|
67 | + $response = $this->_client->request($endpoint, $this->_params); |
|
68 | 68 | return $response->getResponse(); |
69 | 69 | } |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $body = $params['body']; |
74 | 74 | $endpoint = new Debug(); |
75 | 75 | $endpoint->setBody($body); |
76 | - $response = $this->_client->request($endpoint,$this->_params); |
|
76 | + $response = $this->_client->request($endpoint, $this->_params); |
|
77 | 77 | return $response->getResponse(); |
78 | 78 | } |
79 | 79 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $body = $params['body']; |
83 | 83 | $endpoint = new DropFunction(); |
84 | 84 | $endpoint->setBody($body); |
85 | - $response = $this->_client->request($endpoint,$this->_params); |
|
85 | + $response = $this->_client->request($endpoint, $this->_params); |
|
86 | 86 | return $response->getResponse(); |
87 | 87 | } |
88 | 88 | |
@@ -91,61 +91,61 @@ discard block |
||
91 | 91 | $body = $params['body']; |
92 | 92 | $endpoint = new DropPlugin(); |
93 | 93 | $endpoint->setBody($body); |
94 | - $response = $this->_client->request($endpoint,$this->_params); |
|
94 | + $response = $this->_client->request($endpoint, $this->_params); |
|
95 | 95 | return $response->getResponse(); |
96 | 96 | } |
97 | 97 | |
98 | - public function flushattributes($params=[]) |
|
98 | + public function flushattributes($params = []) |
|
99 | 99 | { |
100 | 100 | $body = $params['body']??[]; |
101 | 101 | $endpoint = new FlushAttributes(); |
102 | 102 | $endpoint->setBody($body); |
103 | - $response = $this->_client->request($endpoint,$this->_params); |
|
103 | + $response = $this->_client->request($endpoint, $this->_params); |
|
104 | 104 | return $response->getResponse(); |
105 | 105 | } |
106 | 106 | |
107 | - public function flushhostnames($params=[]) |
|
107 | + public function flushhostnames($params = []) |
|
108 | 108 | { |
109 | 109 | $body = $params['body']??[]; |
110 | 110 | $endpoint = new FlushHostnames(); |
111 | 111 | $endpoint->setBody($body); |
112 | - $response = $this->_client->request($endpoint,$this->_params); |
|
112 | + $response = $this->_client->request($endpoint, $this->_params); |
|
113 | 113 | return $response->getResponse(); |
114 | 114 | } |
115 | 115 | |
116 | - public function flushlogs($params=[]) |
|
116 | + public function flushlogs($params = []) |
|
117 | 117 | { |
118 | 118 | $body = $params['body']??[]; |
119 | 119 | $endpoint = new FlushLogs(); |
120 | 120 | $endpoint->setBody($body); |
121 | - $response = $this->_client->request($endpoint,$this->_params); |
|
121 | + $response = $this->_client->request($endpoint, $this->_params); |
|
122 | 122 | return $response->getResponse(); |
123 | 123 | } |
124 | 124 | |
125 | - public function plugins($params=[]) |
|
125 | + public function plugins($params = []) |
|
126 | 126 | { |
127 | 127 | $body = $params['body']??[]; |
128 | 128 | $endpoint = new Plugins(); |
129 | 129 | $endpoint->setBody($body); |
130 | - $response = $this->_client->request($endpoint,$this->_params); |
|
130 | + $response = $this->_client->request($endpoint, $this->_params); |
|
131 | 131 | return $response->getResponse(); |
132 | 132 | } |
133 | 133 | |
134 | - public function reloadindexes($params=[]) |
|
134 | + public function reloadindexes($params = []) |
|
135 | 135 | { |
136 | 136 | $body = $params['body']??[]; |
137 | 137 | $endpoint = new ReloadIndexes(); |
138 | 138 | $endpoint->setBody($body); |
139 | - $response = $this->_client->request($endpoint,$this->_params); |
|
139 | + $response = $this->_client->request($endpoint, $this->_params); |
|
140 | 140 | return $response->getResponse(); |
141 | 141 | } |
142 | 142 | |
143 | - public function reloadplugins($params=[]) |
|
143 | + public function reloadplugins($params = []) |
|
144 | 144 | { |
145 | 145 | $body = $params['body']??[]; |
146 | 146 | $endpoint = new ReloadPlugins(); |
147 | 147 | $endpoint->setBody($body); |
148 | - $response = $this->_client->request($endpoint,$this->_params); |
|
148 | + $response = $this->_client->request($endpoint, $this->_params); |
|
149 | 149 | return $response->getResponse(); |
150 | 150 | } |
151 | 151 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $body = $params['body']; |
155 | 155 | $endpoint = new Set(); |
156 | 156 | $endpoint->setBody($body); |
157 | - $response = $this->_client->request($endpoint,$this->_params); |
|
157 | + $response = $this->_client->request($endpoint, $this->_params); |
|
158 | 158 | return $response->getResponse(); |
159 | 159 | } |
160 | 160 | |
@@ -162,40 +162,40 @@ discard block |
||
162 | 162 | * @param array $params |
163 | 163 | * @return mixed |
164 | 164 | */ |
165 | - public function status($params=[]) |
|
165 | + public function status($params = []) |
|
166 | 166 | { |
167 | 167 | $body = $params['body']??[]; |
168 | 168 | $endpoint = new Status(); |
169 | 169 | $endpoint->setBody($body); |
170 | - $response = $this->_client->request($endpoint,$this->_params); |
|
170 | + $response = $this->_client->request($endpoint, $this->_params); |
|
171 | 171 | return $response->getResponse(); |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | - public function tables($params=[]) |
|
175 | + public function tables($params = []) |
|
176 | 176 | { |
177 | 177 | $body = $params['body']??[]; |
178 | 178 | $endpoint = new Tables(); |
179 | 179 | $endpoint->setBody($body); |
180 | - $response = $this->_client->request($endpoint,$this->_params); |
|
180 | + $response = $this->_client->request($endpoint, $this->_params); |
|
181 | 181 | return $response->getResponse(); |
182 | 182 | } |
183 | 183 | |
184 | - public function threads($params=[]) |
|
184 | + public function threads($params = []) |
|
185 | 185 | { |
186 | 186 | $body = $params['body']??[]; |
187 | 187 | $endpoint = new Threads(); |
188 | 188 | $endpoint->setBody($body); |
189 | - $response = $this->_client->request($endpoint,$this->_params); |
|
189 | + $response = $this->_client->request($endpoint, $this->_params); |
|
190 | 190 | return $response->getResponse(); |
191 | 191 | } |
192 | 192 | |
193 | - public function variables($params=[]) |
|
193 | + public function variables($params = []) |
|
194 | 194 | { |
195 | 195 | $body = $params['body']??[]; |
196 | 196 | $endpoint = new Variables(); |
197 | 197 | $endpoint->setBody($body); |
198 | - $response = $this->_client->request($endpoint,$this->_params); |
|
198 | + $response = $this->_client->request($endpoint, $this->_params); |
|
199 | 199 | return $response->getResponse(); |
200 | 200 | } |
201 | 201 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | $response = parent::getResponse(); |
12 | 12 | if (isset($response['columns'], $response['data'])) { |
13 | 13 | $data = []; |
14 | - array_walk($response['columns'], static function (&$value, $key) { |
|
14 | + array_walk($response['columns'], static function(&$value, $key) { |
|
15 | 15 | $value = array_keys($value)[0]; |
16 | 16 | }); |
17 | 17 | foreach ($response['data'] as $property) { |
@@ -17,9 +17,9 @@ |
||
17 | 17 | public function setBody($params = null) |
18 | 18 | { |
19 | 19 | if (isset($this->_index)) { |
20 | - if(isset($params['query'])) |
|
20 | + if (isset($params['query'])) |
|
21 | 21 | { |
22 | - return parent::setBody(['query' => "EXPLAIN QUERY ".$this->_index. '\''.$params['query'].'\'']); |
|
22 | + return parent::setBody(['query' => "EXPLAIN QUERY " . $this->_index . '\'' . $params['query'] . '\'']); |
|
23 | 23 | } |
24 | 24 | throw new RuntimeException('Query param is missing.'); |
25 | 25 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | * @param array $params |
29 | 29 | * @return Response |
30 | 30 | */ |
31 | - public function execute(Request $request, $params=[]) |
|
31 | + public function execute(Request $request, $params = []) |
|
32 | 32 | { |
33 | 33 | $connection = $this->getConnection(); |
34 | 34 | $conn = $this->_getCurlConnection($connection->getConfig('persistent')); |
35 | - $url = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort(); |
|
35 | + $url = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort(); |
|
36 | 36 | $endpoint = $request->getPath(); |
37 | 37 | $url .= $endpoint; |
38 | 38 | $url = $this->setupURI($url, $request->getQuery()); |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $method); |
59 | 59 | curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); |
60 | 60 | |
61 | - if ($connection->getConnectTimeout()>0) { |
|
61 | + if ($connection->getConnectTimeout() > 0) { |
|
62 | 62 | curl_setopt($conn, CURLOPT_CONNECTTIMEOUT, $connection->getConnectTimeout()); |
63 | 63 | } |
64 | 64 | |
65 | 65 | if ($connection->getConfig('username') !== null && $connection->getConfig('password') !== null) { |
66 | 66 | curl_setopt($conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY); |
67 | - curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username').":".$connection->getConfig('password')); |
|
67 | + curl_setopt($conn, CURLOPT_USERPWD, $connection->getConfig('username') . ":" . $connection->getConfig('password')); |
|
68 | 68 | } |
69 | 69 | if ($connection->getConfig('proxy') !== null) { |
70 | 70 | curl_setopt($conn, CURLOPT_PROXY, $connection->getConfig('proxy')); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'body' => $request->getBody() |
97 | 97 | ]); |
98 | 98 | //hard error |
99 | - if ($errorno>0) { |
|
99 | + if ($errorno > 0) { |
|
100 | 100 | $error = curl_error($conn); |
101 | 101 | |
102 | 102 | /* @phpstan-ignore-next-line */ |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param bool $persistent |
131 | 131 | * @return false|resource |
132 | 132 | */ |
133 | - protected function _getCurlConnection(bool $persistent=true) |
|
133 | + protected function _getCurlConnection(bool $persistent = true) |
|
134 | 134 | { |
135 | 135 | if (!$persistent || !self::$_curl) { |
136 | 136 | self::$_curl = curl_init(); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function setBody($params = null) |
16 | 16 | { |
17 | 17 | if (isset($this->_index)) { |
18 | - $binds =[]; |
|
18 | + $binds = []; |
|
19 | 19 | $binds[] = "'" . self::escape($params['query']) . "'"; |
20 | 20 | $binds[] = "'" . $this->_index . "'"; |
21 | 21 | if (count($params['options']) > 0) { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $binds[] = "$value AS $name"; |
24 | 24 | } |
25 | 25 | } |
26 | - return parent::setBody( ['query' => "CALL KEYWORDS(" . implode(",", $binds) . ")"]); |
|
26 | + return parent::setBody(['query' => "CALL KEYWORDS(" . implode(",", $binds) . ")"]); |
|
27 | 27 | } |
28 | 28 | throw new RuntimeException('Index name is missing.'); |
29 | 29 |