@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | public function __construct($client) |
38 | 38 | { |
39 | 39 | $this->client = $client; |
40 | - $this->params =['responseClass'=>'Manticoresearch\\Response\\SqlToArray']; |
|
40 | + $this->params = ['responseClass'=>'Manticoresearch\\Response\\SqlToArray']; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function agentstatus($params = []) |
44 | 44 | { |
45 | - $body = $params['body']??[]; |
|
45 | + $body = $params['body'] ?? []; |
|
46 | 46 | $endpoint = new AgentStatus(); |
47 | 47 | $endpoint->setBody($body); |
48 | 48 | $response = $this->client->request($endpoint, $this->params); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | public function flushattributes($params = []) |
98 | 98 | { |
99 | - $body = $params['body']??[]; |
|
99 | + $body = $params['body'] ?? []; |
|
100 | 100 | $endpoint = new FlushAttributes(); |
101 | 101 | $endpoint->setBody($body); |
102 | 102 | $response = $this->client->request($endpoint, $this->params); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | public function flushhostnames($params = []) |
107 | 107 | { |
108 | - $body = $params['body']??[]; |
|
108 | + $body = $params['body'] ?? []; |
|
109 | 109 | $endpoint = new FlushHostnames(); |
110 | 110 | $endpoint->setBody($body); |
111 | 111 | $response = $this->client->request($endpoint, $this->params); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | public function flushlogs($params = []) |
116 | 116 | { |
117 | - $body = $params['body']??[]; |
|
117 | + $body = $params['body'] ?? []; |
|
118 | 118 | $endpoint = new FlushLogs(); |
119 | 119 | $endpoint->setBody($body); |
120 | 120 | $response = $this->client->request($endpoint, $this->params); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | public function plugins($params = []) |
125 | 125 | { |
126 | - $body = $params['body']??[]; |
|
126 | + $body = $params['body'] ?? []; |
|
127 | 127 | $endpoint = new Plugins(); |
128 | 128 | $endpoint->setBody($body); |
129 | 129 | $response = $this->client->request($endpoint, $this->params); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | public function reloadindexes($params = []) |
134 | 134 | { |
135 | - $body = $params['body']??[]; |
|
135 | + $body = $params['body'] ?? []; |
|
136 | 136 | $endpoint = new ReloadIndexes(); |
137 | 137 | $endpoint->setBody($body); |
138 | 138 | $response = $this->client->request($endpoint, $this->params); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | public function reloadplugins($params = []) |
143 | 143 | { |
144 | - $body = $params['body']??[]; |
|
144 | + $body = $params['body'] ?? []; |
|
145 | 145 | $endpoint = new ReloadPlugins(); |
146 | 146 | $endpoint->setBody($body); |
147 | 147 | $response = $this->client->request($endpoint, $this->params); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function status($params = []) |
165 | 165 | { |
166 | - $body = $params['body']??[]; |
|
166 | + $body = $params['body'] ?? []; |
|
167 | 167 | $endpoint = new Status(); |
168 | 168 | $endpoint->setBody($body); |
169 | 169 | $response = $this->client->request($endpoint, $this->params); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | public function tables($params = []) |
174 | 174 | { |
175 | - $body = $params['body']??[]; |
|
175 | + $body = $params['body'] ?? []; |
|
176 | 176 | $endpoint = new Tables(); |
177 | 177 | $endpoint->setBody($body); |
178 | 178 | $response = $this->client->request($endpoint, $this->params); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | public function threads($params = []) |
183 | 183 | { |
184 | - $body = $params['body']??[]; |
|
184 | + $body = $params['body'] ?? []; |
|
185 | 185 | $endpoint = new Threads(); |
186 | 186 | $endpoint->setBody($body); |
187 | 187 | $response = $this->client->request($endpoint, $this->params); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | public function variables($params = []) |
192 | 192 | { |
193 | - $body = $params['body']??[]; |
|
193 | + $body = $params['body'] ?? []; |
|
194 | 194 | $endpoint = new Variables(); |
195 | 195 | $endpoint->setBody($body); |
196 | 196 | $response = $this->client->request($endpoint, $this->params); |
@@ -14,8 +14,8 @@ |
||
14 | 14 | |
15 | 15 | public function getDocsMatched($docs) |
16 | 16 | { |
17 | - return array_map(function ($v) use ($docs) { |
|
18 | - return $docs[$v - 1]; |
|
17 | + return array_map(function($v) use ($docs) { |
|
18 | + return $docs[$v-1]; |
|
19 | 19 | }, $this->data['fields']['_percolator_document_slot']); |
20 | 20 | } |
21 | 21 | } |
@@ -31,6 +31,6 @@ |
||
31 | 31 | |
32 | 32 | public function hasQueries() |
33 | 33 | { |
34 | - return count($this->doc['queries'])>0; |
|
34 | + return count($this->doc['queries']) > 0; |
|
35 | 35 | } |
36 | 36 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | if (isset($query['fields'], $query['fields']['_percolator_document_slot'])) { |
41 | 41 | foreach ($query['fields']['_percolator_document_slot'] as $d) { |
42 | 42 | if (isset($this->array[$d-1])) { |
43 | - $this->array[$d-1]['queries'][] =$query; |
|
43 | + $this->array[$d-1]['queries'][] = $query; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -24,17 +24,17 @@ |
||
24 | 24 | { |
25 | 25 | if (isset($this->cluster)) { |
26 | 26 | if (isset($params['node'])) { |
27 | - return parent::setBody(['query' => "JOIN CLUSTER ".$this->cluster." AT '".$params['node']."'"]); |
|
27 | + return parent::setBody(['query' => "JOIN CLUSTER " . $this->cluster . " AT '" . $params['node'] . "'"]); |
|
28 | 28 | } else { |
29 | - $options =[]; |
|
29 | + $options = []; |
|
30 | 30 | if (isset($params['path'])) { |
31 | - $options[] = "'".$params['path']. "' AS path"; |
|
31 | + $options[] = "'" . $params['path'] . "' AS path"; |
|
32 | 32 | } |
33 | 33 | if (isset($params['nodes'])) { |
34 | - $options[] = "'".$params['nodes']. "' AS nodes"; |
|
34 | + $options[] = "'" . $params['nodes'] . "' AS nodes"; |
|
35 | 35 | } |
36 | - return parent::setBody(['query' => "JOIN CLUSTER ".$this->cluster. |
|
37 | - ((count($options)>0)?" ".implode(',', $options):"")]); |
|
36 | + return parent::setBody(['query' => "JOIN CLUSTER " . $this->cluster . |
|
37 | + ((count($options) > 0) ? " " . implode(',', $options) : "")]); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | throw new RuntimeException('Cluster name is missing.'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function addDocument($data, $id = 0) |
54 | 54 | { |
55 | 55 | if (is_object($data)) { |
56 | - $data = (array) $data; |
|
56 | + $data = (array)$data; |
|
57 | 57 | } elseif (is_string($data)) { |
58 | 58 | $data = json_decode($data, true); |
59 | 59 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $toinsert = []; |
77 | 77 | foreach ($documents as $document) { |
78 | 78 | if (is_object($document)) { |
79 | - $document = (array) $document; |
|
79 | + $document = (array)$document; |
|
80 | 80 | } elseif (is_string($document)) { |
81 | 81 | $document = json_decode($document, true); |
82 | 82 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function replaceDocument($data, $id) |
167 | 167 | { |
168 | 168 | if (is_object($data)) { |
169 | - $data = (array) $data; |
|
169 | + $data = (array)$data; |
|
170 | 170 | } elseif (is_string($data)) { |
171 | 171 | $data = json_decode($data, true); |
172 | 172 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $toreplace = []; |
189 | 189 | foreach ($documents as $document) { |
190 | 190 | if (is_object($document)) { |
191 | - $document = (array) $document; |
|
191 | + $document = (array)$document; |
|
192 | 192 | } elseif (is_string($document)) { |
193 | 193 | $document = json_decode($document, true); |
194 | 194 | } |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | public function highlight($fields = [], $settings = []): self |
110 | 110 | { |
111 | 111 | |
112 | - if (count($fields) === 0 && count($settings)===0) { |
|
113 | - $this->params['highlight'] = new \stdClass(); |
|
112 | + if (count($fields) === 0 && count($settings) === 0) { |
|
113 | + $this->params['highlight'] = new \stdClass(); |
|
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | $this->params['highlight'] = []; |
117 | 117 | if (count($fields) > 0) { |
118 | - $this->params['highlight']['fields'] =$fields; |
|
118 | + $this->params['highlight']['fields'] = $fields; |
|
119 | 119 | } |
120 | - if (count($settings)>0) { |
|
120 | + if (count($settings) > 0) { |
|
121 | 121 | foreach ($settings as $name => $value) { |
122 | - $this->params['highlight'][$name] =$value; |
|
122 | + $this->params['highlight'][$name] = $value; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | return $this; |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | $group = $field; |
258 | 258 | } |
259 | 259 | $terms = ['field'=>$field]; |
260 | - if ($limit !==null) { |
|
260 | + if ($limit !== null) { |
|
261 | 261 | $terms['size'] = $limit; |
262 | 262 | } |
263 | - $this->params['aggs'][$group] =['terms' =>$terms]; |
|
263 | + $this->params['aggs'][$group] = ['terms' =>$terms]; |
|
264 | 264 | return $this; |
265 | 265 | } |
266 | 266 |