@@ -20,27 +20,27 @@ |
||
20 | 20 | |
21 | 21 | class Symfony implements AdapterInterface |
22 | 22 | { |
23 | - public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
|
24 | - { |
|
25 | - $symfonyConfig = []; |
|
26 | - foreach ($config as $key => $value) { |
|
27 | - switch ($key) { |
|
28 | - case RequestOptions::SSL_CERT: |
|
29 | - $symfonyConfig['local_cert'] = $value; |
|
30 | - break; |
|
31 | - case RequestOptions::SSL_KEY: |
|
32 | - $symfonyConfig['local_pk'] = $value; |
|
33 | - break; |
|
34 | - case RequestOptions::SSL_VERIFY: |
|
35 | - $symfonyConfig['verify_host'] = $value; |
|
36 | - $symfonyConfig['verify_peer'] = $value; |
|
37 | - break; |
|
38 | - case RequestOptions::SSL_CA: |
|
39 | - $symfonyConfig['cafile'] = $value; |
|
40 | - } |
|
41 | - } |
|
42 | - $class = get_class($client); |
|
43 | - $httpClient = HttpClient::create(array_merge($clientOptions, $symfonyConfig)); |
|
44 | - return new $class($httpClient); |
|
45 | - } |
|
23 | + public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
|
24 | + { |
|
25 | + $symfonyConfig = []; |
|
26 | + foreach ($config as $key => $value) { |
|
27 | + switch ($key) { |
|
28 | + case RequestOptions::SSL_CERT: |
|
29 | + $symfonyConfig['local_cert'] = $value; |
|
30 | + break; |
|
31 | + case RequestOptions::SSL_KEY: |
|
32 | + $symfonyConfig['local_pk'] = $value; |
|
33 | + break; |
|
34 | + case RequestOptions::SSL_VERIFY: |
|
35 | + $symfonyConfig['verify_host'] = $value; |
|
36 | + $symfonyConfig['verify_peer'] = $value; |
|
37 | + break; |
|
38 | + case RequestOptions::SSL_CA: |
|
39 | + $symfonyConfig['cafile'] = $value; |
|
40 | + } |
|
41 | + } |
|
42 | + $class = get_class($client); |
|
43 | + $httpClient = HttpClient::create(array_merge($clientOptions, $symfonyConfig)); |
|
44 | + return new $class($httpClient); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Transport\Adapter; |
16 | 16 |
@@ -18,8 +18,7 @@ |
||
18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
19 | 19 | use Symfony\Component\HttpClient\HttpClient; |
20 | 20 | |
21 | -class Symfony implements AdapterInterface |
|
22 | -{ |
|
21 | +class Symfony implements AdapterInterface { |
|
23 | 22 | public function setConfig(ClientInterface $client, array $config, array $clientOptions): ClientInterface |
24 | 23 | { |
25 | 24 | $symfonyConfig = []; |
@@ -24,73 +24,73 @@ |
||
24 | 24 | */ |
25 | 25 | trait MessageResponseTrait |
26 | 26 | { |
27 | - public function getProtocolVersion(): string |
|
28 | - { |
|
29 | - return $this->response->getProtocolVersion(); |
|
30 | - } |
|
31 | - |
|
32 | - public function withProtocolVersion($version): MessageInterface |
|
33 | - { |
|
34 | - return $this->response->withProtocolVersion($version); |
|
35 | - } |
|
36 | - |
|
37 | - public function getHeaders(): array |
|
38 | - { |
|
39 | - return $this->response->getHeaders(); |
|
40 | - } |
|
41 | - |
|
42 | - public function hasHeader(string $name): bool |
|
43 | - { |
|
44 | - return $this->response->hasHeader($name); |
|
45 | - } |
|
46 | - |
|
47 | - public function getHeader(string $name): array |
|
48 | - { |
|
49 | - return $this->response->getHeader($name); |
|
50 | - } |
|
51 | - |
|
52 | - public function getHeaderLine(string $name): string |
|
53 | - { |
|
54 | - return $this->response->getHeaderLine($name); |
|
55 | - } |
|
56 | - |
|
57 | - public function withHeader(string $name, $value): MessageInterface |
|
58 | - { |
|
59 | - return $this->response->withHeader($name, $value); |
|
60 | - } |
|
61 | - |
|
62 | - public function withAddedHeader(string $name, $value): MessageInterface |
|
63 | - { |
|
64 | - return $this->response->withAddedHeader($name, $value); |
|
65 | - } |
|
66 | - |
|
67 | - public function withoutHeader(string $name): MessageInterface |
|
68 | - { |
|
69 | - return $this->response->withoutHeader($name); |
|
70 | - } |
|
71 | - |
|
72 | - public function getBody(): StreamInterface |
|
73 | - { |
|
74 | - return $this->response->getBody(); |
|
75 | - } |
|
76 | - |
|
77 | - public function withBody(StreamInterface $body): MessageInterface |
|
78 | - { |
|
79 | - return $this->response->withBody($body); |
|
80 | - } |
|
81 | - |
|
82 | - public function getStatusCode(): int |
|
83 | - { |
|
84 | - return $this->response->getStatusCode(); |
|
85 | - } |
|
86 | - |
|
87 | - public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface |
|
88 | - { |
|
89 | - return $this->response->withStatus($code, $reasonPhrase); |
|
90 | - } |
|
91 | - |
|
92 | - public function getReasonPhrase(): string |
|
93 | - { |
|
94 | - return $this->response->getReasonPhrase(); |
|
95 | - } |
|
27 | + public function getProtocolVersion(): string |
|
28 | + { |
|
29 | + return $this->response->getProtocolVersion(); |
|
30 | + } |
|
31 | + |
|
32 | + public function withProtocolVersion($version): MessageInterface |
|
33 | + { |
|
34 | + return $this->response->withProtocolVersion($version); |
|
35 | + } |
|
36 | + |
|
37 | + public function getHeaders(): array |
|
38 | + { |
|
39 | + return $this->response->getHeaders(); |
|
40 | + } |
|
41 | + |
|
42 | + public function hasHeader(string $name): bool |
|
43 | + { |
|
44 | + return $this->response->hasHeader($name); |
|
45 | + } |
|
46 | + |
|
47 | + public function getHeader(string $name): array |
|
48 | + { |
|
49 | + return $this->response->getHeader($name); |
|
50 | + } |
|
51 | + |
|
52 | + public function getHeaderLine(string $name): string |
|
53 | + { |
|
54 | + return $this->response->getHeaderLine($name); |
|
55 | + } |
|
56 | + |
|
57 | + public function withHeader(string $name, $value): MessageInterface |
|
58 | + { |
|
59 | + return $this->response->withHeader($name, $value); |
|
60 | + } |
|
61 | + |
|
62 | + public function withAddedHeader(string $name, $value): MessageInterface |
|
63 | + { |
|
64 | + return $this->response->withAddedHeader($name, $value); |
|
65 | + } |
|
66 | + |
|
67 | + public function withoutHeader(string $name): MessageInterface |
|
68 | + { |
|
69 | + return $this->response->withoutHeader($name); |
|
70 | + } |
|
71 | + |
|
72 | + public function getBody(): StreamInterface |
|
73 | + { |
|
74 | + return $this->response->getBody(); |
|
75 | + } |
|
76 | + |
|
77 | + public function withBody(StreamInterface $body): MessageInterface |
|
78 | + { |
|
79 | + return $this->response->withBody($body); |
|
80 | + } |
|
81 | + |
|
82 | + public function getStatusCode(): int |
|
83 | + { |
|
84 | + return $this->response->getStatusCode(); |
|
85 | + } |
|
86 | + |
|
87 | + public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface |
|
88 | + { |
|
89 | + return $this->response->withStatus($code, $reasonPhrase); |
|
90 | + } |
|
91 | + |
|
92 | + public function getReasonPhrase(): string |
|
93 | + { |
|
94 | + return $this->response->getReasonPhrase(); |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Traits; |
16 | 16 |
@@ -22,8 +22,7 @@ |
||
22 | 22 | * Proxy class for OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface using |
23 | 23 | * $this->response as source object |
24 | 24 | */ |
25 | -trait MessageResponseTrait |
|
26 | -{ |
|
25 | +trait MessageResponseTrait { |
|
27 | 26 | public function getProtocolVersion(): string |
28 | 27 | { |
29 | 28 | return $this->response->getProtocolVersion(); |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | { |
66 | 66 | $this->checkRequiredParameters(['body'], $params); |
67 | 67 | if (isset($params['index'])) { |
68 | - $url = '/' . $this->encode($params['index']) . '/_bulk'; |
|
68 | + $url = '/'.$this->encode($params['index']).'/_bulk'; |
|
69 | 69 | $method = 'POST'; |
70 | 70 | } else { |
71 | 71 | $url = '/_bulk'; |
72 | 72 | $method = 'POST'; |
73 | 73 | } |
74 | - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','type','_source','_source_excludes','_source_includes','pipeline','require_alias','require_data_stream','list_executed_pipelines','pretty','human','error_trace','source','filter_path']); |
|
74 | + $url = $this->addQueryString($url, $params, ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_includes', 'pipeline', 'require_alias', 'require_data_stream', 'list_executed_pipelines', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
75 | 75 | $headers = [ |
76 | 76 | 'Accept' => 'application/json', |
77 | 77 | 'Content-Type' => 'application/x-ndjson', |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | public function clearScroll(array $params = []) |
105 | 105 | { |
106 | 106 | if (isset($params['scroll_id'])) { |
107 | - $url = '/_search/scroll/' . $this->encode($params['scroll_id']); |
|
107 | + $url = '/_search/scroll/'.$this->encode($params['scroll_id']); |
|
108 | 108 | $method = 'DELETE'; |
109 | 109 | } else { |
110 | 110 | $url = '/_search/scroll'; |
111 | 111 | $method = 'DELETE'; |
112 | 112 | } |
113 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
113 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
114 | 114 | $headers = [ |
115 | 115 | 'Accept' => 'application/json', |
116 | 116 | 'Content-Type' => 'application/json', |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $url = '/_pit'; |
145 | 145 | $method = 'DELETE'; |
146 | 146 | |
147 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
147 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
148 | 148 | $headers = [ |
149 | 149 | 'Accept' => 'application/json', |
150 | 150 | 'Content-Type' => 'application/json', |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | public function count(array $params = []) |
192 | 192 | { |
193 | 193 | if (isset($params['index'])) { |
194 | - $url = '/' . $this->encode($params['index']) . '/_count'; |
|
194 | + $url = '/'.$this->encode($params['index']).'/_count'; |
|
195 | 195 | $method = empty($params['body']) ? 'GET' : 'POST'; |
196 | 196 | } else { |
197 | 197 | $url = '/_count'; |
198 | 198 | $method = empty($params['body']) ? 'GET' : 'POST'; |
199 | 199 | } |
200 | - $url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','min_score','preference','routing','q','analyzer','analyze_wildcard','default_operator','df','lenient','terminate_after','pretty','human','error_trace','source','filter_path']); |
|
200 | + $url = $this->addQueryString($url, $params, ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', 'preference', 'routing', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'terminate_after', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
201 | 201 | $headers = [ |
202 | 202 | 'Accept' => 'application/json', |
203 | 203 | 'Content-Type' => 'application/json', |
@@ -240,11 +240,11 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function create(array $params = []) |
242 | 242 | { |
243 | - $this->checkRequiredParameters(['id','index','body'], $params); |
|
244 | - $url = '/' . $this->encode($params['index']) . '/_create/' . $this->encode($params['id']); |
|
243 | + $this->checkRequiredParameters(['id', 'index', 'body'], $params); |
|
244 | + $url = '/'.$this->encode($params['index']).'/_create/'.$this->encode($params['id']); |
|
245 | 245 | $method = 'PUT'; |
246 | 246 | |
247 | - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','version','version_type','pipeline','pretty','human','error_trace','source','filter_path']); |
|
247 | + $url = $this->addQueryString($url, $params, ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
248 | 248 | $headers = [ |
249 | 249 | 'Accept' => 'application/json', |
250 | 250 | 'Content-Type' => 'application/json', |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function delete(array $params = []) |
287 | 287 | { |
288 | - $this->checkRequiredParameters(['id','index'], $params); |
|
289 | - $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); |
|
288 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
289 | + $url = '/'.$this->encode($params['index']).'/_doc/'.$this->encode($params['id']); |
|
290 | 290 | $method = 'DELETE'; |
291 | 291 | |
292 | - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','if_seq_no','if_primary_term','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
292 | + $url = $this->addQueryString($url, $params, ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
293 | 293 | $headers = [ |
294 | 294 | 'Accept' => 'application/json', |
295 | 295 | ]; |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function deleteByQuery(array $params = []) |
352 | 352 | { |
353 | - $this->checkRequiredParameters(['index','body'], $params); |
|
354 | - $url = '/' . $this->encode($params['index']) . '/_delete_by_query'; |
|
353 | + $this->checkRequiredParameters(['index', 'body'], $params); |
|
354 | + $url = '/'.$this->encode($params['index']).'/_delete_by_query'; |
|
355 | 355 | $method = 'POST'; |
356 | 356 | |
357 | - $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']); |
|
357 | + $url = $this->addQueryString($url, $params, ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', 'terminate_after', 'stats', 'version', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
358 | 358 | $headers = [ |
359 | 359 | 'Accept' => 'application/json', |
360 | 360 | 'Content-Type' => 'application/json', |
@@ -387,11 +387,11 @@ discard block |
||
387 | 387 | */ |
388 | 388 | public function deleteByQueryRethrottle(array $params = []) |
389 | 389 | { |
390 | - $this->checkRequiredParameters(['task_id','requests_per_second'], $params); |
|
391 | - $url = '/_delete_by_query/' . $this->encode($params['task_id']) . '/_rethrottle'; |
|
390 | + $this->checkRequiredParameters(['task_id', 'requests_per_second'], $params); |
|
391 | + $url = '/_delete_by_query/'.$this->encode($params['task_id']).'/_rethrottle'; |
|
392 | 392 | $method = 'POST'; |
393 | 393 | |
394 | - $url = $this->addQueryString($url, $params, ['requests_per_second','pretty','human','error_trace','source','filter_path']); |
|
394 | + $url = $this->addQueryString($url, $params, ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
395 | 395 | $headers = [ |
396 | 396 | 'Accept' => 'application/json', |
397 | 397 | ]; |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | public function deleteScript(array $params = []) |
426 | 426 | { |
427 | 427 | $this->checkRequiredParameters(['id'], $params); |
428 | - $url = '/_scripts/' . $this->encode($params['id']); |
|
428 | + $url = '/_scripts/'.$this->encode($params['id']); |
|
429 | 429 | $method = 'DELETE'; |
430 | 430 | |
431 | - $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); |
|
431 | + $url = $this->addQueryString($url, $params, ['timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
432 | 432 | $headers = [ |
433 | 433 | 'Accept' => 'application/json', |
434 | 434 | ]; |
@@ -470,11 +470,11 @@ discard block |
||
470 | 470 | */ |
471 | 471 | public function exists(array $params = []) |
472 | 472 | { |
473 | - $this->checkRequiredParameters(['id','index'], $params); |
|
474 | - $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); |
|
473 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
474 | + $url = '/'.$this->encode($params['index']).'/_doc/'.$this->encode($params['id']); |
|
475 | 475 | $method = 'HEAD'; |
476 | 476 | |
477 | - $url = $this->addQueryString($url, $params, ['stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
477 | + $url = $this->addQueryString($url, $params, ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_includes', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
478 | 478 | $headers = [ |
479 | 479 | 'Accept' => 'application/json', |
480 | 480 | ]; |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | */ |
516 | 516 | public function existsSource(array $params = []) |
517 | 517 | { |
518 | - $this->checkRequiredParameters(['id','index'], $params); |
|
519 | - $url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']); |
|
518 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
519 | + $url = '/'.$this->encode($params['index']).'/_source/'.$this->encode($params['id']); |
|
520 | 520 | $method = 'HEAD'; |
521 | 521 | |
522 | - $url = $this->addQueryString($url, $params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
522 | + $url = $this->addQueryString($url, $params, ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_includes', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
523 | 523 | $headers = [ |
524 | 524 | 'Accept' => 'application/json', |
525 | 525 | ]; |
@@ -564,11 +564,11 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function explain(array $params = []) |
566 | 566 | { |
567 | - $this->checkRequiredParameters(['id','index'], $params); |
|
568 | - $url = '/' . $this->encode($params['index']) . '/_explain/' . $this->encode($params['id']); |
|
567 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
568 | + $url = '/'.$this->encode($params['index']).'/_explain/'.$this->encode($params['id']); |
|
569 | 569 | $method = empty($params['body']) ? 'GET' : 'POST'; |
570 | 570 | |
571 | - $url = $this->addQueryString($url, $params, ['analyze_wildcard','analyzer','default_operator','df','stored_fields','lenient','preference','q','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']); |
|
571 | + $url = $this->addQueryString($url, $params, ['analyze_wildcard', 'analyzer', 'default_operator', 'df', 'stored_fields', 'lenient', 'preference', 'q', 'routing', '_source', '_source_excludes', '_source_includes', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
572 | 572 | $headers = [ |
573 | 573 | 'Accept' => 'application/json', |
574 | 574 | 'Content-Type' => 'application/json', |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | public function fieldCaps(array $params = []) |
610 | 610 | { |
611 | 611 | if (isset($params['index'])) { |
612 | - $url = '/' . $this->encode($params['index']) . '/_field_caps'; |
|
612 | + $url = '/'.$this->encode($params['index']).'/_field_caps'; |
|
613 | 613 | $method = empty($params['body']) ? 'GET' : 'POST'; |
614 | 614 | } else { |
615 | 615 | $url = '/_field_caps'; |
616 | 616 | $method = empty($params['body']) ? 'GET' : 'POST'; |
617 | 617 | } |
618 | - $url = $this->addQueryString($url, $params, ['fields','ignore_unavailable','allow_no_indices','expand_wildcards','include_unmapped','filters','types','include_empty_fields','pretty','human','error_trace','source','filter_path']); |
|
618 | + $url = $this->addQueryString($url, $params, ['fields', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'include_unmapped', 'filters', 'types', 'include_empty_fields', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
619 | 619 | $headers = [ |
620 | 620 | 'Accept' => 'application/json', |
621 | 621 | 'Content-Type' => 'application/json', |
@@ -659,11 +659,11 @@ discard block |
||
659 | 659 | */ |
660 | 660 | public function get(array $params = []) |
661 | 661 | { |
662 | - $this->checkRequiredParameters(['id','index'], $params); |
|
663 | - $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); |
|
662 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
663 | + $url = '/'.$this->encode($params['index']).'/_doc/'.$this->encode($params['id']); |
|
664 | 664 | $method = 'GET'; |
665 | 665 | |
666 | - $url = $this->addQueryString($url, $params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
666 | + $url = $this->addQueryString($url, $params, ['force_synthetic_source', 'stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_includes', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
667 | 667 | $headers = [ |
668 | 668 | 'Accept' => 'application/json', |
669 | 669 | ]; |
@@ -696,10 +696,10 @@ discard block |
||
696 | 696 | public function getScript(array $params = []) |
697 | 697 | { |
698 | 698 | $this->checkRequiredParameters(['id'], $params); |
699 | - $url = '/_scripts/' . $this->encode($params['id']); |
|
699 | + $url = '/_scripts/'.$this->encode($params['id']); |
|
700 | 700 | $method = 'GET'; |
701 | 701 | |
702 | - $url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']); |
|
702 | + $url = $this->addQueryString($url, $params, ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
703 | 703 | $headers = [ |
704 | 704 | 'Accept' => 'application/json', |
705 | 705 | ]; |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $url = '/_script_context'; |
732 | 732 | $method = 'GET'; |
733 | 733 | |
734 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
734 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
735 | 735 | $headers = [ |
736 | 736 | 'Accept' => 'application/json', |
737 | 737 | ]; |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | $url = '/_script_language'; |
764 | 764 | $method = 'GET'; |
765 | 765 | |
766 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
766 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
767 | 767 | $headers = [ |
768 | 768 | 'Accept' => 'application/json', |
769 | 769 | ]; |
@@ -804,11 +804,11 @@ discard block |
||
804 | 804 | */ |
805 | 805 | public function getSource(array $params = []) |
806 | 806 | { |
807 | - $this->checkRequiredParameters(['id','index'], $params); |
|
808 | - $url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']); |
|
807 | + $this->checkRequiredParameters(['id', 'index'], $params); |
|
808 | + $url = '/'.$this->encode($params['index']).'/_source/'.$this->encode($params['id']); |
|
809 | 809 | $method = 'GET'; |
810 | 810 | |
811 | - $url = $this->addQueryString($url, $params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
811 | + $url = $this->addQueryString($url, $params, ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_includes', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
812 | 812 | $headers = [ |
813 | 813 | 'Accept' => 'application/json', |
814 | 814 | ]; |
@@ -842,13 +842,13 @@ discard block |
||
842 | 842 | public function healthReport(array $params = []) |
843 | 843 | { |
844 | 844 | if (isset($params['feature'])) { |
845 | - $url = '/_health_report/' . $this->encode($params['feature']); |
|
845 | + $url = '/_health_report/'.$this->encode($params['feature']); |
|
846 | 846 | $method = 'GET'; |
847 | 847 | } else { |
848 | 848 | $url = '/_health_report'; |
849 | 849 | $method = 'GET'; |
850 | 850 | } |
851 | - $url = $this->addQueryString($url, $params, ['timeout','verbose','size','pretty','human','error_trace','source','filter_path']); |
|
851 | + $url = $this->addQueryString($url, $params, ['timeout', 'verbose', 'size', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
852 | 852 | $headers = [ |
853 | 853 | 'Accept' => 'application/json', |
854 | 854 | ]; |
@@ -893,15 +893,15 @@ discard block |
||
893 | 893 | */ |
894 | 894 | public function index(array $params = []) |
895 | 895 | { |
896 | - $this->checkRequiredParameters(['index','body'], $params); |
|
896 | + $this->checkRequiredParameters(['index', 'body'], $params); |
|
897 | 897 | if (isset($params['id'])) { |
898 | - $url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']); |
|
898 | + $url = '/'.$this->encode($params['index']).'/_doc/'.$this->encode($params['id']); |
|
899 | 899 | $method = 'PUT'; |
900 | 900 | } else { |
901 | - $url = '/' . $this->encode($params['index']) . '/_doc'; |
|
901 | + $url = '/'.$this->encode($params['index']).'/_doc'; |
|
902 | 902 | $method = 'POST'; |
903 | 903 | } |
904 | - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','require_data_stream','pretty','human','error_trace','source','filter_path']); |
|
904 | + $url = $this->addQueryString($url, $params, ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'require_alias', 'require_data_stream', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
905 | 905 | $headers = [ |
906 | 906 | 'Accept' => 'application/json', |
907 | 907 | 'Content-Type' => 'application/json', |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | $url = '/'; |
935 | 935 | $method = 'GET'; |
936 | 936 | |
937 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
937 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
938 | 938 | $headers = [ |
939 | 939 | 'Accept' => 'application/json', |
940 | 940 | ]; |
@@ -969,10 +969,10 @@ discard block |
||
969 | 969 | public function knnSearch(array $params = []) |
970 | 970 | { |
971 | 971 | $this->checkRequiredParameters(['index'], $params); |
972 | - $url = '/' . $this->encode($params['index']) . '/_knn_search'; |
|
972 | + $url = '/'.$this->encode($params['index']).'/_knn_search'; |
|
973 | 973 | $method = empty($params['body']) ? 'GET' : 'POST'; |
974 | 974 | |
975 | - $url = $this->addQueryString($url, $params, ['routing','pretty','human','error_trace','source','filter_path']); |
|
975 | + $url = $this->addQueryString($url, $params, ['routing', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
976 | 976 | $headers = [ |
977 | 977 | 'Accept' => 'application/json', |
978 | 978 | 'Content-Type' => 'application/json', |
@@ -1015,13 +1015,13 @@ discard block |
||
1015 | 1015 | { |
1016 | 1016 | $this->checkRequiredParameters(['body'], $params); |
1017 | 1017 | if (isset($params['index'])) { |
1018 | - $url = '/' . $this->encode($params['index']) . '/_mget'; |
|
1018 | + $url = '/'.$this->encode($params['index']).'/_mget'; |
|
1019 | 1019 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1020 | 1020 | } else { |
1021 | 1021 | $url = '/_mget'; |
1022 | 1022 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1023 | 1023 | } |
1024 | - $url = $this->addQueryString($url, $params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']); |
|
1024 | + $url = $this->addQueryString($url, $params, ['force_synthetic_source', 'stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_includes', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1025 | 1025 | $headers = [ |
1026 | 1026 | 'Accept' => 'application/json', |
1027 | 1027 | 'Content-Type' => 'application/json', |
@@ -1062,13 +1062,13 @@ discard block |
||
1062 | 1062 | { |
1063 | 1063 | $this->checkRequiredParameters(['body'], $params); |
1064 | 1064 | if (isset($params['index'])) { |
1065 | - $url = '/' . $this->encode($params['index']) . '/_msearch'; |
|
1065 | + $url = '/'.$this->encode($params['index']).'/_msearch'; |
|
1066 | 1066 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1067 | 1067 | } else { |
1068 | 1068 | $url = '/_msearch'; |
1069 | 1069 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1070 | 1070 | } |
1071 | - $url = $this->addQueryString($url, $params, ['search_type','max_concurrent_searches','typed_keys','pre_filter_shard_size','max_concurrent_shard_requests','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']); |
|
1071 | + $url = $this->addQueryString($url, $params, ['search_type', 'max_concurrent_searches', 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1072 | 1072 | $headers = [ |
1073 | 1073 | 'Accept' => 'application/json', |
1074 | 1074 | 'Content-Type' => 'application/x-ndjson', |
@@ -1107,13 +1107,13 @@ discard block |
||
1107 | 1107 | { |
1108 | 1108 | $this->checkRequiredParameters(['body'], $params); |
1109 | 1109 | if (isset($params['index'])) { |
1110 | - $url = '/' . $this->encode($params['index']) . '/_msearch/template'; |
|
1110 | + $url = '/'.$this->encode($params['index']).'/_msearch/template'; |
|
1111 | 1111 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1112 | 1112 | } else { |
1113 | 1113 | $url = '/_msearch/template'; |
1114 | 1114 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1115 | 1115 | } |
1116 | - $url = $this->addQueryString($url, $params, ['search_type','typed_keys','max_concurrent_searches','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']); |
|
1116 | + $url = $this->addQueryString($url, $params, ['search_type', 'typed_keys', 'max_concurrent_searches', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1117 | 1117 | $headers = [ |
1118 | 1118 | 'Accept' => 'application/json', |
1119 | 1119 | 'Content-Type' => 'application/x-ndjson', |
@@ -1158,13 +1158,13 @@ discard block |
||
1158 | 1158 | public function mtermvectors(array $params = []) |
1159 | 1159 | { |
1160 | 1160 | if (isset($params['index'])) { |
1161 | - $url = '/' . $this->encode($params['index']) . '/_mtermvectors'; |
|
1161 | + $url = '/'.$this->encode($params['index']).'/_mtermvectors'; |
|
1162 | 1162 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1163 | 1163 | } else { |
1164 | 1164 | $url = '/_mtermvectors'; |
1165 | 1165 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1166 | 1166 | } |
1167 | - $url = $this->addQueryString($url, $params, ['ids','term_statistics','field_statistics','fields','offsets','positions','payloads','preference','routing','realtime','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
1167 | + $url = $this->addQueryString($url, $params, ['ids', 'term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1168 | 1168 | $headers = [ |
1169 | 1169 | 'Accept' => 'application/json', |
1170 | 1170 | 'Content-Type' => 'application/json', |
@@ -1202,11 +1202,11 @@ discard block |
||
1202 | 1202 | */ |
1203 | 1203 | public function openPointInTime(array $params = []) |
1204 | 1204 | { |
1205 | - $this->checkRequiredParameters(['index','keep_alive'], $params); |
|
1206 | - $url = '/' . $this->encode($params['index']) . '/_pit'; |
|
1205 | + $this->checkRequiredParameters(['index', 'keep_alive'], $params); |
|
1206 | + $url = '/'.$this->encode($params['index']).'/_pit'; |
|
1207 | 1207 | $method = 'POST'; |
1208 | 1208 | |
1209 | - $url = $this->addQueryString($url, $params, ['preference','routing','ignore_unavailable','expand_wildcards','keep_alive','pretty','human','error_trace','source','filter_path']); |
|
1209 | + $url = $this->addQueryString($url, $params, ['preference', 'routing', 'ignore_unavailable', 'expand_wildcards', 'keep_alive', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1210 | 1210 | $headers = [ |
1211 | 1211 | 'Accept' => 'application/json', |
1212 | 1212 | 'Content-Type' => 'application/json', |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | $url = '/'; |
1240 | 1240 | $method = 'HEAD'; |
1241 | 1241 | |
1242 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
1242 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1243 | 1243 | $headers = [ |
1244 | 1244 | 'Accept' => 'application/json', |
1245 | 1245 | ]; |
@@ -1274,15 +1274,15 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | public function putScript(array $params = []) |
1276 | 1276 | { |
1277 | - $this->checkRequiredParameters(['id','body'], $params); |
|
1277 | + $this->checkRequiredParameters(['id', 'body'], $params); |
|
1278 | 1278 | if (isset($params['context'])) { |
1279 | - $url = '/_scripts/' . $this->encode($params['id']) . '/' . $this->encode($params['context']); |
|
1279 | + $url = '/_scripts/'.$this->encode($params['id']).'/'.$this->encode($params['context']); |
|
1280 | 1280 | $method = 'PUT'; |
1281 | 1281 | } else { |
1282 | - $url = '/_scripts/' . $this->encode($params['id']); |
|
1282 | + $url = '/_scripts/'.$this->encode($params['id']); |
|
1283 | 1283 | $method = 'PUT'; |
1284 | 1284 | } |
1285 | - $url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']); |
|
1285 | + $url = $this->addQueryString($url, $params, ['timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1286 | 1286 | $headers = [ |
1287 | 1287 | 'Accept' => 'application/json', |
1288 | 1288 | 'Content-Type' => 'application/json', |
@@ -1320,13 +1320,13 @@ discard block |
||
1320 | 1320 | { |
1321 | 1321 | $this->checkRequiredParameters(['body'], $params); |
1322 | 1322 | if (isset($params['index'])) { |
1323 | - $url = '/' . $this->encode($params['index']) . '/_rank_eval'; |
|
1323 | + $url = '/'.$this->encode($params['index']).'/_rank_eval'; |
|
1324 | 1324 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1325 | 1325 | } else { |
1326 | 1326 | $url = '/_rank_eval'; |
1327 | 1327 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1328 | 1328 | } |
1329 | - $url = $this->addQueryString($url, $params, ['ignore_unavailable','allow_no_indices','expand_wildcards','search_type','pretty','human','error_trace','source','filter_path']); |
|
1329 | + $url = $this->addQueryString($url, $params, ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'search_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1330 | 1330 | $headers = [ |
1331 | 1331 | 'Accept' => 'application/json', |
1332 | 1332 | 'Content-Type' => 'application/json', |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | $url = '/_reindex'; |
1372 | 1372 | $method = 'POST'; |
1373 | 1373 | |
1374 | - $url = $this->addQueryString($url, $params, ['refresh','timeout','wait_for_active_shards','wait_for_completion','requests_per_second','scroll','slices','max_docs','pretty','human','error_trace','source','filter_path']); |
|
1374 | + $url = $this->addQueryString($url, $params, ['refresh', 'timeout', 'wait_for_active_shards', 'wait_for_completion', 'requests_per_second', 'scroll', 'slices', 'max_docs', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1375 | 1375 | $headers = [ |
1376 | 1376 | 'Accept' => 'application/json', |
1377 | 1377 | 'Content-Type' => 'application/json', |
@@ -1404,11 +1404,11 @@ discard block |
||
1404 | 1404 | */ |
1405 | 1405 | public function reindexRethrottle(array $params = []) |
1406 | 1406 | { |
1407 | - $this->checkRequiredParameters(['task_id','requests_per_second'], $params); |
|
1408 | - $url = '/_reindex/' . $this->encode($params['task_id']) . '/_rethrottle'; |
|
1407 | + $this->checkRequiredParameters(['task_id', 'requests_per_second'], $params); |
|
1408 | + $url = '/_reindex/'.$this->encode($params['task_id']).'/_rethrottle'; |
|
1409 | 1409 | $method = 'POST'; |
1410 | 1410 | |
1411 | - $url = $this->addQueryString($url, $params, ['requests_per_second','pretty','human','error_trace','source','filter_path']); |
|
1411 | + $url = $this->addQueryString($url, $params, ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1412 | 1412 | $headers = [ |
1413 | 1413 | 'Accept' => 'application/json', |
1414 | 1414 | ]; |
@@ -1440,13 +1440,13 @@ discard block |
||
1440 | 1440 | public function renderSearchTemplate(array $params = []) |
1441 | 1441 | { |
1442 | 1442 | if (isset($params['id'])) { |
1443 | - $url = '/_render/template/' . $this->encode($params['id']); |
|
1443 | + $url = '/_render/template/'.$this->encode($params['id']); |
|
1444 | 1444 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1445 | 1445 | } else { |
1446 | 1446 | $url = '/_render/template'; |
1447 | 1447 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1448 | 1448 | } |
1449 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
1449 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1450 | 1450 | $headers = [ |
1451 | 1451 | 'Accept' => 'application/json', |
1452 | 1452 | 'Content-Type' => 'application/json', |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | $url = '/_scripts/painless/_execute'; |
1482 | 1482 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1483 | 1483 | |
1484 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
1484 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1485 | 1485 | $headers = [ |
1486 | 1486 | 'Accept' => 'application/json', |
1487 | 1487 | 'Content-Type' => 'application/json', |
@@ -1516,13 +1516,13 @@ discard block |
||
1516 | 1516 | public function scroll(array $params = []) |
1517 | 1517 | { |
1518 | 1518 | if (isset($params['scroll_id'])) { |
1519 | - $url = '/_search/scroll/' . $this->encode($params['scroll_id']); |
|
1519 | + $url = '/_search/scroll/'.$this->encode($params['scroll_id']); |
|
1520 | 1520 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1521 | 1521 | } else { |
1522 | 1522 | $url = '/_search/scroll'; |
1523 | 1523 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1524 | 1524 | } |
1525 | - $url = $this->addQueryString($url, $params, ['scroll','rest_total_hits_as_int','pretty','human','error_trace','source','filter_path']); |
|
1525 | + $url = $this->addQueryString($url, $params, ['scroll', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1526 | 1526 | $headers = [ |
1527 | 1527 | 'Accept' => 'application/json', |
1528 | 1528 | 'Content-Type' => 'application/json', |
@@ -1600,13 +1600,13 @@ discard block |
||
1600 | 1600 | public function search(array $params = []) |
1601 | 1601 | { |
1602 | 1602 | if (isset($params['index'])) { |
1603 | - $url = '/' . $this->encode($params['index']) . '/_search'; |
|
1603 | + $url = '/'.$this->encode($params['index']).'/_search'; |
|
1604 | 1604 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1605 | 1605 | } else { |
1606 | 1606 | $url = '/_search'; |
1607 | 1607 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1608 | 1608 | } |
1609 | - $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','ccs_minimize_roundtrips','default_operator','df','explain','stored_fields','docvalue_fields','from','force_synthetic_source','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','scroll','search_type','size','sort','_source','_source_excludes','_source_includes','terminate_after','stats','suggest_field','suggest_mode','suggest_size','suggest_text','timeout','track_scores','track_total_hits','allow_partial_search_results','typed_keys','version','seq_no_primary_term','request_cache','batched_reduce_size','max_concurrent_shard_requests','pre_filter_shard_size','rest_total_hits_as_int','min_compatible_shard_node','include_named_queries_score','pretty','human','error_trace','source','filter_path']); |
|
1609 | + $url = $this->addQueryString($url, $params, ['analyzer', 'analyze_wildcard', 'ccs_minimize_roundtrips', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'force_synthetic_source', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_includes', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'typed_keys', 'version', 'seq_no_primary_term', 'request_cache', 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', 'rest_total_hits_as_int', 'min_compatible_shard_node', 'include_named_queries_score', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1610 | 1610 | $headers = [ |
1611 | 1611 | 'Accept' => 'application/json', |
1612 | 1612 | 'Content-Type' => 'application/json', |
@@ -1651,11 +1651,11 @@ discard block |
||
1651 | 1651 | */ |
1652 | 1652 | public function searchMvt(array $params = []) |
1653 | 1653 | { |
1654 | - $this->checkRequiredParameters(['index','field','zoom','x','y'], $params); |
|
1655 | - $url = '/' . $this->encode($params['index']) . '/_mvt/' . $this->encode($params['field']) . '/' . $this->encode($params['zoom']) . '/' . $this->encode($params['x']) . '/' . $this->encode($params['y']); |
|
1654 | + $this->checkRequiredParameters(['index', 'field', 'zoom', 'x', 'y'], $params); |
|
1655 | + $url = '/'.$this->encode($params['index']).'/_mvt/'.$this->encode($params['field']).'/'.$this->encode($params['zoom']).'/'.$this->encode($params['x']).'/'.$this->encode($params['y']); |
|
1656 | 1656 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1657 | 1657 | |
1658 | - $url = $this->addQueryString($url, $params, ['exact_bounds','extent','grid_precision','grid_type','size','track_total_hits','with_labels','pretty','human','error_trace','source','filter_path']); |
|
1658 | + $url = $this->addQueryString($url, $params, ['exact_bounds', 'extent', 'grid_precision', 'grid_type', 'size', 'track_total_hits', 'with_labels', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1659 | 1659 | $headers = [ |
1660 | 1660 | 'Accept' => 'application/vnd.mapbox-vector-tile', |
1661 | 1661 | 'Content-Type' => 'application/json', |
@@ -1693,13 +1693,13 @@ discard block |
||
1693 | 1693 | public function searchShards(array $params = []) |
1694 | 1694 | { |
1695 | 1695 | if (isset($params['index'])) { |
1696 | - $url = '/' . $this->encode($params['index']) . '/_search_shards'; |
|
1696 | + $url = '/'.$this->encode($params['index']).'/_search_shards'; |
|
1697 | 1697 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1698 | 1698 | } else { |
1699 | 1699 | $url = '/_search_shards'; |
1700 | 1700 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1701 | 1701 | } |
1702 | - $url = $this->addQueryString($url, $params, ['preference','routing','local','ignore_unavailable','allow_no_indices','expand_wildcards','pretty','human','error_trace','source','filter_path']); |
|
1702 | + $url = $this->addQueryString($url, $params, ['preference', 'routing', 'local', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1703 | 1703 | $headers = [ |
1704 | 1704 | 'Accept' => 'application/json', |
1705 | 1705 | ]; |
@@ -1745,13 +1745,13 @@ discard block |
||
1745 | 1745 | { |
1746 | 1746 | $this->checkRequiredParameters(['body'], $params); |
1747 | 1747 | if (isset($params['index'])) { |
1748 | - $url = '/' . $this->encode($params['index']) . '/_search/template'; |
|
1748 | + $url = '/'.$this->encode($params['index']).'/_search/template'; |
|
1749 | 1749 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1750 | 1750 | } else { |
1751 | 1751 | $url = '/_search/template'; |
1752 | 1752 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1753 | 1753 | } |
1754 | - $url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','preference','routing','scroll','search_type','explain','profile','typed_keys','rest_total_hits_as_int','ccs_minimize_roundtrips','pretty','human','error_trace','source','filter_path']); |
|
1754 | + $url = $this->addQueryString($url, $params, ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', 'routing', 'scroll', 'search_type', 'explain', 'profile', 'typed_keys', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1755 | 1755 | $headers = [ |
1756 | 1756 | 'Accept' => 'application/json', |
1757 | 1757 | 'Content-Type' => 'application/json', |
@@ -1785,10 +1785,10 @@ discard block |
||
1785 | 1785 | public function termsEnum(array $params = []) |
1786 | 1786 | { |
1787 | 1787 | $this->checkRequiredParameters(['index'], $params); |
1788 | - $url = '/' . $this->encode($params['index']) . '/_terms_enum'; |
|
1788 | + $url = '/'.$this->encode($params['index']).'/_terms_enum'; |
|
1789 | 1789 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1790 | 1790 | |
1791 | - $url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']); |
|
1791 | + $url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1792 | 1792 | $headers = [ |
1793 | 1793 | 'Accept' => 'application/json', |
1794 | 1794 | 'Content-Type' => 'application/json', |
@@ -1835,13 +1835,13 @@ discard block |
||
1835 | 1835 | { |
1836 | 1836 | $this->checkRequiredParameters(['index'], $params); |
1837 | 1837 | if (isset($params['id'])) { |
1838 | - $url = '/' . $this->encode($params['index']) . '/_termvectors/' . $this->encode($params['id']); |
|
1838 | + $url = '/'.$this->encode($params['index']).'/_termvectors/'.$this->encode($params['id']); |
|
1839 | 1839 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1840 | 1840 | } else { |
1841 | - $url = '/' . $this->encode($params['index']) . '/_termvectors'; |
|
1841 | + $url = '/'.$this->encode($params['index']).'/_termvectors'; |
|
1842 | 1842 | $method = empty($params['body']) ? 'GET' : 'POST'; |
1843 | 1843 | } |
1844 | - $url = $this->addQueryString($url, $params, ['term_statistics','field_statistics','fields','offsets','positions','payloads','preference','routing','realtime','version','version_type','pretty','human','error_trace','source','filter_path']); |
|
1844 | + $url = $this->addQueryString($url, $params, ['term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1845 | 1845 | $headers = [ |
1846 | 1846 | 'Accept' => 'application/json', |
1847 | 1847 | 'Content-Type' => 'application/json', |
@@ -1887,11 +1887,11 @@ discard block |
||
1887 | 1887 | */ |
1888 | 1888 | public function update(array $params = []) |
1889 | 1889 | { |
1890 | - $this->checkRequiredParameters(['id','index','body'], $params); |
|
1891 | - $url = '/' . $this->encode($params['index']) . '/_update/' . $this->encode($params['id']); |
|
1890 | + $this->checkRequiredParameters(['id', 'index', 'body'], $params); |
|
1891 | + $url = '/'.$this->encode($params['index']).'/_update/'.$this->encode($params['id']); |
|
1892 | 1892 | $method = 'POST'; |
1893 | 1893 | |
1894 | - $url = $this->addQueryString($url, $params, ['wait_for_active_shards','_source','_source_excludes','_source_includes','lang','refresh','retry_on_conflict','routing','timeout','if_seq_no','if_primary_term','require_alias','pretty','human','error_trace','source','filter_path']); |
|
1894 | + $url = $this->addQueryString($url, $params, ['wait_for_active_shards', '_source', '_source_excludes', '_source_includes', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1895 | 1895 | $headers = [ |
1896 | 1896 | 'Accept' => 'application/json', |
1897 | 1897 | 'Content-Type' => 'application/json', |
@@ -1957,10 +1957,10 @@ discard block |
||
1957 | 1957 | public function updateByQuery(array $params = []) |
1958 | 1958 | { |
1959 | 1959 | $this->checkRequiredParameters(['index'], $params); |
1960 | - $url = '/' . $this->encode($params['index']) . '/_update_by_query'; |
|
1960 | + $url = '/'.$this->encode($params['index']).'/_update_by_query'; |
|
1961 | 1961 | $method = 'POST'; |
1962 | 1962 | |
1963 | - $url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','pipeline','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','version_type','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']); |
|
1963 | + $url = $this->addQueryString($url, $params, ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'pipeline', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', 'terminate_after', 'stats', 'version', 'version_type', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
1964 | 1964 | $headers = [ |
1965 | 1965 | 'Accept' => 'application/json', |
1966 | 1966 | 'Content-Type' => 'application/json', |
@@ -1993,11 +1993,11 @@ discard block |
||
1993 | 1993 | */ |
1994 | 1994 | public function updateByQueryRethrottle(array $params = []) |
1995 | 1995 | { |
1996 | - $this->checkRequiredParameters(['task_id','requests_per_second'], $params); |
|
1997 | - $url = '/_update_by_query/' . $this->encode($params['task_id']) . '/_rethrottle'; |
|
1996 | + $this->checkRequiredParameters(['task_id', 'requests_per_second'], $params); |
|
1997 | + $url = '/_update_by_query/'.$this->encode($params['task_id']).'/_rethrottle'; |
|
1998 | 1998 | $method = 'POST'; |
1999 | 1999 | |
2000 | - $url = $this->addQueryString($url, $params, ['requests_per_second','pretty','human','error_trace','source','filter_path']); |
|
2000 | + $url = $this->addQueryString($url, $params, ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path']); |
|
2001 | 2001 | $headers = [ |
2002 | 2002 | 'Accept' => 'application/json', |
2003 | 2003 | ]; |
@@ -26,8 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * @generated This file is generated, please do not edit |
28 | 28 | */ |
29 | -trait ClientEndpointsTrait |
|
30 | -{ |
|
29 | +trait ClientEndpointsTrait { |
|
31 | 30 | /** |
32 | 31 | * Allows to perform multiple index/update/delete operations in a single request. |
33 | 32 | * |
@@ -20,19 +20,19 @@ |
||
20 | 20 | |
21 | 21 | trait ProductCheckTrait |
22 | 22 | { |
23 | - /** |
|
24 | - * Check if the response comes from Elasticsearch server |
|
25 | - */ |
|
26 | - private function productCheck(ResponseInterface $response): void |
|
27 | - { |
|
28 | - $statusCode = (int) $response->getStatusCode(); |
|
29 | - if ($statusCode >= 200 && $statusCode < 300) { |
|
30 | - $product = $response->getHeaderLine(Elasticsearch::HEADER_CHECK); |
|
31 | - if (empty($product) || $product !== Elasticsearch::PRODUCT_NAME) { |
|
32 | - throw new ProductCheckException( |
|
33 | - 'The client noticed that the server is not Elasticsearch and we do not support this unknown product' |
|
34 | - ); |
|
35 | - } |
|
36 | - } |
|
37 | - } |
|
23 | + /** |
|
24 | + * Check if the response comes from Elasticsearch server |
|
25 | + */ |
|
26 | + private function productCheck(ResponseInterface $response): void |
|
27 | + { |
|
28 | + $statusCode = (int) $response->getStatusCode(); |
|
29 | + if ($statusCode >= 200 && $statusCode < 300) { |
|
30 | + $product = $response->getHeaderLine(Elasticsearch::HEADER_CHECK); |
|
31 | + if (empty($product) || $product !== Elasticsearch::PRODUCT_NAME) { |
|
32 | + throw new ProductCheckException( |
|
33 | + 'The client noticed that the server is not Elasticsearch and we do not support this unknown product' |
|
34 | + ); |
|
35 | + } |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Traits; |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | private function productCheck(ResponseInterface $response): void |
27 | 27 | { |
28 | - $statusCode = (int) $response->getStatusCode(); |
|
28 | + $statusCode = (int)$response->getStatusCode(); |
|
29 | 29 | if ($statusCode >= 200 && $statusCode < 300) { |
30 | 30 | $product = $response->getHeaderLine(Elasticsearch::HEADER_CHECK); |
31 | 31 | if (empty($product) || $product !== Elasticsearch::PRODUCT_NAME) { |
@@ -18,8 +18,7 @@ |
||
18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Response\Elasticsearch; |
19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
20 | 20 | |
21 | -trait ProductCheckTrait |
|
22 | -{ |
|
21 | +trait ProductCheckTrait { |
|
23 | 22 | /** |
24 | 23 | * Check if the response comes from Elasticsearch server |
25 | 24 | */ |
@@ -62,8 +62,7 @@ |
||
62 | 62 | /** |
63 | 63 | * @generated This file is generated, please do not edit |
64 | 64 | */ |
65 | -trait NamespaceTrait |
|
66 | -{ |
|
65 | +trait NamespaceTrait { |
|
67 | 66 | /** The endpoint namespace storage */ |
68 | 67 | protected array $namespace; |
69 | 68 |
@@ -18,16 +18,16 @@ |
||
18 | 18 | |
19 | 19 | trait ResponseTrait |
20 | 20 | { |
21 | - protected ResponseInterface $response; |
|
21 | + protected ResponseInterface $response; |
|
22 | 22 | |
23 | - public function setResponse(ResponseInterface $response): self |
|
24 | - { |
|
25 | - $this->response = $response; |
|
26 | - return $this; |
|
27 | - } |
|
23 | + public function setResponse(ResponseInterface $response): self |
|
24 | + { |
|
25 | + $this->response = $response; |
|
26 | + return $this; |
|
27 | + } |
|
28 | 28 | |
29 | - public function getResponse(): ResponseInterface |
|
30 | - { |
|
31 | - return $this->response; |
|
32 | - } |
|
29 | + public function getResponse(): ResponseInterface |
|
30 | + { |
|
31 | + return $this->response; |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | \ No newline at end of file |
@@ -16,8 +16,7 @@ |
||
16 | 16 | |
17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
18 | 18 | |
19 | -trait ResponseTrait |
|
20 | -{ |
|
19 | +trait ResponseTrait { |
|
21 | 20 | protected ResponseInterface $response; |
22 | 21 | |
23 | 22 | public function setResponse(ResponseInterface $response): self |
@@ -29,169 +29,169 @@ |
||
29 | 29 | |
30 | 30 | trait EndpointTrait |
31 | 31 | { |
32 | - /** |
|
33 | - * Check if an array containts nested array |
|
34 | - */ |
|
35 | - private function isNestedArray(array $a): bool |
|
36 | - { |
|
37 | - foreach ($a as $v) { |
|
38 | - if (is_array($v)) { |
|
39 | - return true; |
|
40 | - } |
|
41 | - } |
|
42 | - return false; |
|
43 | - } |
|
32 | + /** |
|
33 | + * Check if an array containts nested array |
|
34 | + */ |
|
35 | + private function isNestedArray(array $a): bool |
|
36 | + { |
|
37 | + foreach ($a as $v) { |
|
38 | + if (is_array($v)) { |
|
39 | + return true; |
|
40 | + } |
|
41 | + } |
|
42 | + return false; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Check if an array is associative, i.e. has a string as key |
|
47 | - */ |
|
48 | - protected function isAssociativeArray(array $array): bool |
|
49 | - { |
|
50 | - foreach ($array as $k => $v) { |
|
51 | - if (is_string($k)) { |
|
52 | - return true; |
|
53 | - } |
|
54 | - } |
|
55 | - return false; |
|
56 | - } |
|
45 | + /** |
|
46 | + * Check if an array is associative, i.e. has a string as key |
|
47 | + */ |
|
48 | + protected function isAssociativeArray(array $array): bool |
|
49 | + { |
|
50 | + foreach ($array as $k => $v) { |
|
51 | + if (is_string($k)) { |
|
52 | + return true; |
|
53 | + } |
|
54 | + } |
|
55 | + return false; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Converts array to comma-separated list; |
|
60 | - * Converts boolean value to true', 'false' string |
|
61 | - * |
|
62 | - * @param mixed $value |
|
63 | - */ |
|
64 | - private function convertValue($value): string |
|
65 | - { |
|
66 | - // Convert a boolean value in 'true' or 'false' string |
|
67 | - if (is_bool($value)) { |
|
68 | - return $value ? 'true' : 'false'; |
|
69 | - // Convert to comma-separated list if array |
|
70 | - } elseif (is_array($value) && $this->isNestedArray($value) === false) { |
|
71 | - return implode(',', $value); |
|
72 | - } |
|
73 | - return (string) $value; |
|
74 | - } |
|
58 | + /** |
|
59 | + * Converts array to comma-separated list; |
|
60 | + * Converts boolean value to true', 'false' string |
|
61 | + * |
|
62 | + * @param mixed $value |
|
63 | + */ |
|
64 | + private function convertValue($value): string |
|
65 | + { |
|
66 | + // Convert a boolean value in 'true' or 'false' string |
|
67 | + if (is_bool($value)) { |
|
68 | + return $value ? 'true' : 'false'; |
|
69 | + // Convert to comma-separated list if array |
|
70 | + } elseif (is_array($value) && $this->isNestedArray($value) === false) { |
|
71 | + return implode(',', $value); |
|
72 | + } |
|
73 | + return (string) $value; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Encode a value for a valid URL |
|
78 | - * |
|
79 | - * @param mixed $value |
|
80 | - */ |
|
81 | - protected function encode($value): string |
|
82 | - { |
|
83 | - return Utility::urlencode($this->convertValue($value)); |
|
84 | - } |
|
76 | + /** |
|
77 | + * Encode a value for a valid URL |
|
78 | + * |
|
79 | + * @param mixed $value |
|
80 | + */ |
|
81 | + protected function encode($value): string |
|
82 | + { |
|
83 | + return Utility::urlencode($this->convertValue($value)); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Returns the URL with the query string from $params |
|
88 | - * extracting the array keys specified in $keys |
|
89 | - */ |
|
90 | - protected function addQueryString(string $url, array $params, array $keys): string |
|
91 | - { |
|
92 | - $queryParams = []; |
|
93 | - foreach ($keys as $k) { |
|
94 | - if (isset($params[$k])) { |
|
95 | - $queryParams[$k] = $this->convertValue($params[$k]); |
|
96 | - } |
|
97 | - } |
|
98 | - if (empty($queryParams)) { |
|
99 | - return $url; |
|
100 | - } |
|
101 | - return $url . '?' . http_build_query($queryParams); |
|
102 | - } |
|
86 | + /** |
|
87 | + * Returns the URL with the query string from $params |
|
88 | + * extracting the array keys specified in $keys |
|
89 | + */ |
|
90 | + protected function addQueryString(string $url, array $params, array $keys): string |
|
91 | + { |
|
92 | + $queryParams = []; |
|
93 | + foreach ($keys as $k) { |
|
94 | + if (isset($params[$k])) { |
|
95 | + $queryParams[$k] = $this->convertValue($params[$k]); |
|
96 | + } |
|
97 | + } |
|
98 | + if (empty($queryParams)) { |
|
99 | + return $url; |
|
100 | + } |
|
101 | + return $url . '?' . http_build_query($queryParams); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Serialize the body using the Content-Type |
|
106 | - * |
|
107 | - * @param mixed $body |
|
108 | - */ |
|
109 | - protected function bodySerialize($body, string $contentType): string |
|
110 | - { |
|
111 | - if (strpos($contentType, 'application/x-ndjson') !== false || |
|
112 | - strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
113 | - return NDJsonSerializer::serialize($body, ['remove_null' => false]); |
|
114 | - } |
|
115 | - if (strpos($contentType, 'application/json') !== false || |
|
116 | - strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
117 | - return JsonSerializer::serialize($body, ['remove_null' => false]); |
|
118 | - } |
|
119 | - throw new ContentTypeException(sprintf( |
|
120 | - "The Content-Type %s is not managed by Elasticsearch serializer", |
|
121 | - $contentType |
|
122 | - )); |
|
123 | - } |
|
104 | + /** |
|
105 | + * Serialize the body using the Content-Type |
|
106 | + * |
|
107 | + * @param mixed $body |
|
108 | + */ |
|
109 | + protected function bodySerialize($body, string $contentType): string |
|
110 | + { |
|
111 | + if (strpos($contentType, 'application/x-ndjson') !== false || |
|
112 | + strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
113 | + return NDJsonSerializer::serialize($body, ['remove_null' => false]); |
|
114 | + } |
|
115 | + if (strpos($contentType, 'application/json') !== false || |
|
116 | + strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
117 | + return JsonSerializer::serialize($body, ['remove_null' => false]); |
|
118 | + } |
|
119 | + throw new ContentTypeException(sprintf( |
|
120 | + "The Content-Type %s is not managed by Elasticsearch serializer", |
|
121 | + $contentType |
|
122 | + )); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Create a PSR-7 request |
|
127 | - * |
|
128 | - * @param array|string $body |
|
129 | - */ |
|
130 | - protected function createRequest(string $method, string $url, array $headers, $body = null): RequestInterface |
|
131 | - { |
|
132 | - $requestFactory = Psr17FactoryDiscovery::findRequestFactory(); |
|
133 | - $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); |
|
125 | + /** |
|
126 | + * Create a PSR-7 request |
|
127 | + * |
|
128 | + * @param array|string $body |
|
129 | + */ |
|
130 | + protected function createRequest(string $method, string $url, array $headers, $body = null): RequestInterface |
|
131 | + { |
|
132 | + $requestFactory = Psr17FactoryDiscovery::findRequestFactory(); |
|
133 | + $streamFactory = Psr17FactoryDiscovery::findStreamFactory(); |
|
134 | 134 | |
135 | - $request = $requestFactory->createRequest($method, $url); |
|
136 | - // Body request |
|
137 | - if (!empty($body)) { |
|
138 | - if (!isset($headers['Content-Type'])) { |
|
139 | - throw new ContentTypeException(sprintf( |
|
140 | - "The Content-Type is missing for %s %s", |
|
141 | - $method, |
|
142 | - $url |
|
143 | - )); |
|
144 | - } |
|
145 | - $content = is_string($body) ? $body : $this->bodySerialize($body, $headers['Content-Type']); |
|
146 | - $request = $request->withBody($streamFactory->createStream($content)); |
|
147 | - } |
|
148 | - $headers = $this->buildCompatibilityHeaders($headers); |
|
135 | + $request = $requestFactory->createRequest($method, $url); |
|
136 | + // Body request |
|
137 | + if (!empty($body)) { |
|
138 | + if (!isset($headers['Content-Type'])) { |
|
139 | + throw new ContentTypeException(sprintf( |
|
140 | + "The Content-Type is missing for %s %s", |
|
141 | + $method, |
|
142 | + $url |
|
143 | + )); |
|
144 | + } |
|
145 | + $content = is_string($body) ? $body : $this->bodySerialize($body, $headers['Content-Type']); |
|
146 | + $request = $request->withBody($streamFactory->createStream($content)); |
|
147 | + } |
|
148 | + $headers = $this->buildCompatibilityHeaders($headers); |
|
149 | 149 | |
150 | - // Headers |
|
151 | - foreach ($headers as $name => $value) { |
|
152 | - $request = $request->withHeader($name, $value); |
|
153 | - } |
|
154 | - return $request; |
|
155 | - } |
|
150 | + // Headers |
|
151 | + foreach ($headers as $name => $value) { |
|
152 | + $request = $request->withHeader($name, $value); |
|
153 | + } |
|
154 | + return $request; |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Build the API compatibility headers |
|
159 | - * transfrom Content-Type and Accept adding vnd.elasticsearch+ and compatible-with |
|
160 | - * |
|
161 | - * @see https://github.com/elastic/elasticsearch-php/pull/1142 |
|
162 | - */ |
|
163 | - protected function buildCompatibilityHeaders(array $headers): array |
|
164 | - { |
|
165 | - if (isset($headers['Content-Type'])) { |
|
166 | - if (preg_match('/application\/([^,]+)$/', $headers['Content-Type'], $matches)) { |
|
167 | - $headers['Content-Type'] = sprintf(Client::API_COMPATIBILITY_HEADER, 'application', $matches[1]); |
|
168 | - } |
|
169 | - } |
|
170 | - if (isset($headers['Accept'])) { |
|
171 | - $values = explode(',', $headers['Accept']); |
|
172 | - foreach ($values as &$value) { |
|
173 | - if (preg_match('/(application|text)\/([^,]+)/', $value, $matches)) { |
|
174 | - $value = sprintf(Client::API_COMPATIBILITY_HEADER, $matches[1], $matches[2]); |
|
175 | - } |
|
176 | - } |
|
177 | - $headers['Accept'] = implode(',', $values); |
|
178 | - } |
|
179 | - return $headers; |
|
180 | - } |
|
157 | + /** |
|
158 | + * Build the API compatibility headers |
|
159 | + * transfrom Content-Type and Accept adding vnd.elasticsearch+ and compatible-with |
|
160 | + * |
|
161 | + * @see https://github.com/elastic/elasticsearch-php/pull/1142 |
|
162 | + */ |
|
163 | + protected function buildCompatibilityHeaders(array $headers): array |
|
164 | + { |
|
165 | + if (isset($headers['Content-Type'])) { |
|
166 | + if (preg_match('/application\/([^,]+)$/', $headers['Content-Type'], $matches)) { |
|
167 | + $headers['Content-Type'] = sprintf(Client::API_COMPATIBILITY_HEADER, 'application', $matches[1]); |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($headers['Accept'])) { |
|
171 | + $values = explode(',', $headers['Accept']); |
|
172 | + foreach ($values as &$value) { |
|
173 | + if (preg_match('/(application|text)\/([^,]+)/', $value, $matches)) { |
|
174 | + $value = sprintf(Client::API_COMPATIBILITY_HEADER, $matches[1], $matches[2]); |
|
175 | + } |
|
176 | + } |
|
177 | + $headers['Accept'] = implode(',', $values); |
|
178 | + } |
|
179 | + return $headers; |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * Check if the $required parameters are present in $params |
|
184 | - * @throws MissingParameterException |
|
185 | - */ |
|
186 | - protected function checkRequiredParameters(array $required, array $params): void |
|
187 | - { |
|
188 | - foreach ($required as $req) { |
|
189 | - if (!isset($params[$req])) { |
|
190 | - throw new MissingParameterException(sprintf( |
|
191 | - 'The parameter %s is required', |
|
192 | - $req |
|
193 | - )); |
|
194 | - } |
|
195 | - } |
|
196 | - } |
|
182 | + /** |
|
183 | + * Check if the $required parameters are present in $params |
|
184 | + * @throws MissingParameterException |
|
185 | + */ |
|
186 | + protected function checkRequiredParameters(array $required, array $params): void |
|
187 | + { |
|
188 | + foreach ($required as $req) { |
|
189 | + if (!isset($params[$req])) { |
|
190 | + throw new MissingParameterException(sprintf( |
|
191 | + 'The parameter %s is required', |
|
192 | + $req |
|
193 | + )); |
|
194 | + } |
|
195 | + } |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Traits; |
16 | 16 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } elseif (is_array($value) && $this->isNestedArray($value) === false) { |
71 | 71 | return implode(',', $value); |
72 | 72 | } |
73 | - return (string) $value; |
|
73 | + return (string)$value; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if (empty($queryParams)) { |
99 | 99 | return $url; |
100 | 100 | } |
101 | - return $url . '?' . http_build_query($queryParams); |
|
101 | + return $url.'?'.http_build_query($queryParams); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -27,8 +27,7 @@ |
||
27 | 27 | use function strpos; |
28 | 28 | use function sprintf; |
29 | 29 | |
30 | -trait EndpointTrait |
|
31 | -{ |
|
30 | +trait EndpointTrait { |
|
32 | 31 | /** |
33 | 32 | * Check if an array containts nested array |
34 | 33 | */ |
@@ -35,255 +35,255 @@ |
||
35 | 35 | */ |
36 | 36 | class Elasticsearch implements ElasticsearchInterface, ResponseInterface, ArrayAccess |
37 | 37 | { |
38 | - const HEADER_CHECK = 'X-Elastic-Product'; |
|
39 | - const PRODUCT_NAME = 'Elasticsearch'; |
|
38 | + const HEADER_CHECK = 'X-Elastic-Product'; |
|
39 | + const PRODUCT_NAME = 'Elasticsearch'; |
|
40 | 40 | |
41 | - use ProductCheckTrait; |
|
42 | - use MessageResponseTrait; |
|
41 | + use ProductCheckTrait; |
|
42 | + use MessageResponseTrait; |
|
43 | 43 | |
44 | - protected array $asArray; |
|
45 | - protected object $asObject; |
|
46 | - protected string $asString; |
|
44 | + protected array $asArray; |
|
45 | + protected object $asObject; |
|
46 | + protected string $asString; |
|
47 | 47 | |
48 | - /** |
|
49 | - * The PSR-7 response |
|
50 | - */ |
|
51 | - protected ResponseInterface $response; |
|
48 | + /** |
|
49 | + * The PSR-7 response |
|
50 | + */ |
|
51 | + protected ResponseInterface $response; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Enable or disable the response Exception |
|
55 | - */ |
|
56 | - protected bool $responseException; |
|
53 | + /** |
|
54 | + * Enable or disable the response Exception |
|
55 | + */ |
|
56 | + protected bool $responseException; |
|
57 | 57 | |
58 | - /** |
|
59 | - * @throws ClientResponseException if status code 4xx |
|
60 | - * @throws ServerResponseException if status code 5xx |
|
61 | - */ |
|
62 | - public function setResponse(ResponseInterface $response, bool $throwException = true): void |
|
63 | - { |
|
64 | - $this->productCheck($response); |
|
65 | - $this->response = $response; |
|
66 | - $status = $response->getStatusCode(); |
|
67 | - if ($throwException && $status > 399 && $status < 500) { |
|
68 | - $error = new ClientResponseException( |
|
69 | - sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
70 | - $status |
|
71 | - ); |
|
72 | - throw $error->setResponse($response); |
|
73 | - } elseif ($throwException && $status > 499 && $status < 600) { |
|
74 | - $error = new ServerResponseException( |
|
75 | - sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
76 | - $status |
|
77 | - ); |
|
78 | - throw $error->setResponse($response); |
|
79 | - } |
|
80 | - } |
|
58 | + /** |
|
59 | + * @throws ClientResponseException if status code 4xx |
|
60 | + * @throws ServerResponseException if status code 5xx |
|
61 | + */ |
|
62 | + public function setResponse(ResponseInterface $response, bool $throwException = true): void |
|
63 | + { |
|
64 | + $this->productCheck($response); |
|
65 | + $this->response = $response; |
|
66 | + $status = $response->getStatusCode(); |
|
67 | + if ($throwException && $status > 399 && $status < 500) { |
|
68 | + $error = new ClientResponseException( |
|
69 | + sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
70 | + $status |
|
71 | + ); |
|
72 | + throw $error->setResponse($response); |
|
73 | + } elseif ($throwException && $status > 499 && $status < 600) { |
|
74 | + $error = new ServerResponseException( |
|
75 | + sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
76 | + $status |
|
77 | + ); |
|
78 | + throw $error->setResponse($response); |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Return true if status code is 2xx |
|
84 | - */ |
|
85 | - public function asBool(): bool |
|
86 | - { |
|
87 | - return $this->response->getStatusCode() >=200 && $this->response->getStatusCode() < 300; |
|
88 | - } |
|
82 | + /** |
|
83 | + * Return true if status code is 2xx |
|
84 | + */ |
|
85 | + public function asBool(): bool |
|
86 | + { |
|
87 | + return $this->response->getStatusCode() >=200 && $this->response->getStatusCode() < 300; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Converts the body content to array, if possible. |
|
92 | - * Otherwise, it throws an UnknownContentTypeException |
|
93 | - * if Content-Type is not specified or unknown. |
|
94 | - * |
|
95 | - * @throws UnknownContentTypeException |
|
96 | - */ |
|
97 | - public function asArray(): array |
|
98 | - { |
|
99 | - if (isset($this->asArray)) { |
|
100 | - return $this->asArray; |
|
101 | - } |
|
102 | - if (!$this->response->hasHeader('Content-Type')) { |
|
103 | - throw new UnknownContentTypeException('No Content-Type specified in the response'); |
|
104 | - } |
|
105 | - $contentType = $this->response->getHeaderLine('Content-Type'); |
|
106 | - if (strpos($contentType, 'application/json') !== false || |
|
107 | - strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
108 | - $this->asArray = JsonSerializer::unserialize($this->asString()); |
|
109 | - return $this->asArray; |
|
110 | - } |
|
111 | - if (strpos($contentType, 'application/x-ndjson') !== false || |
|
112 | - strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
113 | - $this->asArray = NDJsonSerializer::unserialize($this->asString()); |
|
114 | - return $this->asArray; |
|
115 | - } |
|
116 | - if (strpos($contentType, 'text/csv') !== false) { |
|
117 | - $this->asArray = CsvSerializer::unserialize($this->asString()); |
|
118 | - return $this->asArray; |
|
119 | - } |
|
120 | - throw new UnknownContentTypeException(sprintf( |
|
121 | - "Cannot deserialize the reponse as array with Content-Type: %s", |
|
122 | - $contentType |
|
123 | - )); |
|
124 | - } |
|
90 | + /** |
|
91 | + * Converts the body content to array, if possible. |
|
92 | + * Otherwise, it throws an UnknownContentTypeException |
|
93 | + * if Content-Type is not specified or unknown. |
|
94 | + * |
|
95 | + * @throws UnknownContentTypeException |
|
96 | + */ |
|
97 | + public function asArray(): array |
|
98 | + { |
|
99 | + if (isset($this->asArray)) { |
|
100 | + return $this->asArray; |
|
101 | + } |
|
102 | + if (!$this->response->hasHeader('Content-Type')) { |
|
103 | + throw new UnknownContentTypeException('No Content-Type specified in the response'); |
|
104 | + } |
|
105 | + $contentType = $this->response->getHeaderLine('Content-Type'); |
|
106 | + if (strpos($contentType, 'application/json') !== false || |
|
107 | + strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
108 | + $this->asArray = JsonSerializer::unserialize($this->asString()); |
|
109 | + return $this->asArray; |
|
110 | + } |
|
111 | + if (strpos($contentType, 'application/x-ndjson') !== false || |
|
112 | + strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
113 | + $this->asArray = NDJsonSerializer::unserialize($this->asString()); |
|
114 | + return $this->asArray; |
|
115 | + } |
|
116 | + if (strpos($contentType, 'text/csv') !== false) { |
|
117 | + $this->asArray = CsvSerializer::unserialize($this->asString()); |
|
118 | + return $this->asArray; |
|
119 | + } |
|
120 | + throw new UnknownContentTypeException(sprintf( |
|
121 | + "Cannot deserialize the reponse as array with Content-Type: %s", |
|
122 | + $contentType |
|
123 | + )); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Converts the body content to object, if possible. |
|
128 | - * Otherwise, it throws an UnknownContentTypeException |
|
129 | - * if Content-Type is not specified or unknown. |
|
130 | - * |
|
131 | - * @throws UnknownContentTypeException |
|
132 | - */ |
|
133 | - public function asObject(): object |
|
134 | - { |
|
135 | - if (isset($this->asObject)) { |
|
136 | - return $this->asObject; |
|
137 | - } |
|
138 | - $contentType = $this->response->getHeaderLine('Content-Type'); |
|
139 | - if (strpos($contentType, 'application/json') !== false || |
|
140 | - strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
141 | - $this->asObject = JsonSerializer::unserialize($this->asString(), ['type' => 'object']); |
|
142 | - return $this->asObject; |
|
143 | - } |
|
144 | - if (strpos($contentType, 'application/x-ndjson') !== false || |
|
145 | - strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
146 | - $this->asObject = NDJsonSerializer::unserialize($this->asString(), ['type' => 'object']); |
|
147 | - return $this->asObject; |
|
148 | - } |
|
149 | - if (strpos($contentType, 'text/xml') !== false || strpos($contentType, 'application/xml') !== false) { |
|
150 | - $this->asObject = XmlSerializer::unserialize($this->asString()); |
|
151 | - return $this->asObject; |
|
152 | - } |
|
153 | - throw new UnknownContentTypeException(sprintf( |
|
154 | - "Cannot deserialize the reponse as object with Content-Type: %s", |
|
155 | - $contentType |
|
156 | - )); |
|
157 | - } |
|
126 | + /** |
|
127 | + * Converts the body content to object, if possible. |
|
128 | + * Otherwise, it throws an UnknownContentTypeException |
|
129 | + * if Content-Type is not specified or unknown. |
|
130 | + * |
|
131 | + * @throws UnknownContentTypeException |
|
132 | + */ |
|
133 | + public function asObject(): object |
|
134 | + { |
|
135 | + if (isset($this->asObject)) { |
|
136 | + return $this->asObject; |
|
137 | + } |
|
138 | + $contentType = $this->response->getHeaderLine('Content-Type'); |
|
139 | + if (strpos($contentType, 'application/json') !== false || |
|
140 | + strpos($contentType, 'application/vnd.elasticsearch+json') !== false) { |
|
141 | + $this->asObject = JsonSerializer::unserialize($this->asString(), ['type' => 'object']); |
|
142 | + return $this->asObject; |
|
143 | + } |
|
144 | + if (strpos($contentType, 'application/x-ndjson') !== false || |
|
145 | + strpos($contentType, 'application/vnd.elasticsearch+x-ndjson') !== false) { |
|
146 | + $this->asObject = NDJsonSerializer::unserialize($this->asString(), ['type' => 'object']); |
|
147 | + return $this->asObject; |
|
148 | + } |
|
149 | + if (strpos($contentType, 'text/xml') !== false || strpos($contentType, 'application/xml') !== false) { |
|
150 | + $this->asObject = XmlSerializer::unserialize($this->asString()); |
|
151 | + return $this->asObject; |
|
152 | + } |
|
153 | + throw new UnknownContentTypeException(sprintf( |
|
154 | + "Cannot deserialize the reponse as object with Content-Type: %s", |
|
155 | + $contentType |
|
156 | + )); |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Converts the body content to string |
|
161 | - */ |
|
162 | - public function asString(): string |
|
163 | - { |
|
164 | - if (empty($this->asString)) { |
|
165 | - $this->asString = (string) $this->response->getBody(); |
|
166 | - } |
|
167 | - return $this->asString; |
|
168 | - } |
|
159 | + /** |
|
160 | + * Converts the body content to string |
|
161 | + */ |
|
162 | + public function asString(): string |
|
163 | + { |
|
164 | + if (empty($this->asString)) { |
|
165 | + $this->asString = (string) $this->response->getBody(); |
|
166 | + } |
|
167 | + return $this->asString; |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Converts the body content to string |
|
172 | - */ |
|
173 | - public function __toString(): string |
|
174 | - { |
|
175 | - return $this->asString(); |
|
176 | - } |
|
170 | + /** |
|
171 | + * Converts the body content to string |
|
172 | + */ |
|
173 | + public function __toString(): string |
|
174 | + { |
|
175 | + return $this->asString(); |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Access the body content as object properties |
|
180 | - * |
|
181 | - * @see https://www.php.net/manual/en/language.oop5.overloading.php#object.get |
|
182 | - */ |
|
183 | - public function __get($name) |
|
184 | - { |
|
185 | - return $this->asObject()->$name ?? null; |
|
186 | - } |
|
178 | + /** |
|
179 | + * Access the body content as object properties |
|
180 | + * |
|
181 | + * @see https://www.php.net/manual/en/language.oop5.overloading.php#object.get |
|
182 | + */ |
|
183 | + public function __get($name) |
|
184 | + { |
|
185 | + return $this->asObject()->$name ?? null; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * ArrayAccess interface |
|
190 | - * |
|
191 | - * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
192 | - */ |
|
193 | - public function offsetExists($offset): bool |
|
194 | - { |
|
195 | - return isset($this->asArray()[$offset]); |
|
196 | - } |
|
188 | + /** |
|
189 | + * ArrayAccess interface |
|
190 | + * |
|
191 | + * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
192 | + */ |
|
193 | + public function offsetExists($offset): bool |
|
194 | + { |
|
195 | + return isset($this->asArray()[$offset]); |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * ArrayAccess interface |
|
200 | - * |
|
201 | - * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
202 | - * |
|
203 | - * @return mixed |
|
204 | - */ |
|
205 | - #[\ReturnTypeWillChange] |
|
206 | - public function offsetGet($offset) |
|
207 | - { |
|
208 | - return $this->asArray()[$offset]; |
|
209 | - } |
|
198 | + /** |
|
199 | + * ArrayAccess interface |
|
200 | + * |
|
201 | + * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
202 | + * |
|
203 | + * @return mixed |
|
204 | + */ |
|
205 | + #[\ReturnTypeWillChange] |
|
206 | + public function offsetGet($offset) |
|
207 | + { |
|
208 | + return $this->asArray()[$offset]; |
|
209 | + } |
|
210 | 210 | |
211 | - /** |
|
212 | - * ArrayAccess interface |
|
213 | - * |
|
214 | - * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
215 | - */ |
|
216 | - public function offsetSet($offset, $value): void |
|
217 | - { |
|
218 | - throw new ArrayAccessException('The array is reading only'); |
|
219 | - } |
|
211 | + /** |
|
212 | + * ArrayAccess interface |
|
213 | + * |
|
214 | + * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
215 | + */ |
|
216 | + public function offsetSet($offset, $value): void |
|
217 | + { |
|
218 | + throw new ArrayAccessException('The array is reading only'); |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * ArrayAccess interface |
|
223 | - * |
|
224 | - * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
225 | - */ |
|
226 | - public function offsetUnset($offset): void |
|
227 | - { |
|
228 | - throw new ArrayAccessException('The array is reading only'); |
|
229 | - } |
|
221 | + /** |
|
222 | + * ArrayAccess interface |
|
223 | + * |
|
224 | + * @see https://www.php.net/manual/en/class.arrayaccess.php |
|
225 | + */ |
|
226 | + public function offsetUnset($offset): void |
|
227 | + { |
|
228 | + throw new ArrayAccessException('The array is reading only'); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * Map the response body to an object of a specific class |
|
233 | - * by default the class is the PHP standard one (stdClass) |
|
234 | - * |
|
235 | - * This mapping works only for ES|QL results (with columns and values) |
|
236 | - * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html |
|
237 | - * |
|
238 | - * @return object[] |
|
239 | - */ |
|
240 | - public function mapTo(string $class = stdClass::class): array |
|
241 | - { |
|
242 | - $response = $this->asArray(); |
|
243 | - if (!isset($response['columns']) || !isset($response['values'])) { |
|
244 | - throw new UnknownContentTypeException(sprintf( |
|
245 | - "The response is not a valid ES|QL result. I cannot mapTo(\"%s\")", |
|
246 | - $class |
|
247 | - )); |
|
248 | - } |
|
249 | - $iterator = []; |
|
250 | - $ncol = count($response['columns']); |
|
251 | - foreach ($response['values'] as $value) { |
|
252 | - $obj = new $class; |
|
253 | - for ($i=0; $i < $ncol; $i++) { |
|
254 | - $field = Utility::formatVariableName($response['columns'][$i]['name']); |
|
255 | - if ($class !== stdClass::class && !property_exists($obj, $field)) { |
|
256 | - continue; |
|
257 | - } |
|
258 | - switch($response['columns'][$i]['type']) { |
|
259 | - case 'boolean': |
|
260 | - $obj->{$field} = (bool) $value[$i]; |
|
261 | - break; |
|
262 | - case 'date': |
|
263 | - $obj->{$field} = new DateTime($value[$i]); |
|
264 | - break; |
|
265 | - case 'alias': |
|
266 | - case 'text': |
|
267 | - case 'keyword': |
|
268 | - case 'ip': |
|
269 | - $obj->{$field} = (string) $value[$i]; |
|
270 | - break; |
|
271 | - case 'integer': |
|
272 | - $obj->{$field} = (int) $value[$i]; |
|
273 | - break; |
|
274 | - case 'long': |
|
275 | - case 'double': |
|
276 | - $obj->{$field} = (float) $value[$i]; |
|
277 | - break; |
|
278 | - case 'null': |
|
279 | - $obj->{$field} = null; |
|
280 | - break; |
|
281 | - default: |
|
282 | - $obj->{$field} = $value[$i]; |
|
283 | - } |
|
284 | - } |
|
285 | - $iterator[] = $obj; |
|
286 | - } |
|
287 | - return $iterator; |
|
288 | - } |
|
231 | + /** |
|
232 | + * Map the response body to an object of a specific class |
|
233 | + * by default the class is the PHP standard one (stdClass) |
|
234 | + * |
|
235 | + * This mapping works only for ES|QL results (with columns and values) |
|
236 | + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/esql.html |
|
237 | + * |
|
238 | + * @return object[] |
|
239 | + */ |
|
240 | + public function mapTo(string $class = stdClass::class): array |
|
241 | + { |
|
242 | + $response = $this->asArray(); |
|
243 | + if (!isset($response['columns']) || !isset($response['values'])) { |
|
244 | + throw new UnknownContentTypeException(sprintf( |
|
245 | + "The response is not a valid ES|QL result. I cannot mapTo(\"%s\")", |
|
246 | + $class |
|
247 | + )); |
|
248 | + } |
|
249 | + $iterator = []; |
|
250 | + $ncol = count($response['columns']); |
|
251 | + foreach ($response['values'] as $value) { |
|
252 | + $obj = new $class; |
|
253 | + for ($i=0; $i < $ncol; $i++) { |
|
254 | + $field = Utility::formatVariableName($response['columns'][$i]['name']); |
|
255 | + if ($class !== stdClass::class && !property_exists($obj, $field)) { |
|
256 | + continue; |
|
257 | + } |
|
258 | + switch($response['columns'][$i]['type']) { |
|
259 | + case 'boolean': |
|
260 | + $obj->{$field} = (bool) $value[$i]; |
|
261 | + break; |
|
262 | + case 'date': |
|
263 | + $obj->{$field} = new DateTime($value[$i]); |
|
264 | + break; |
|
265 | + case 'alias': |
|
266 | + case 'text': |
|
267 | + case 'keyword': |
|
268 | + case 'ip': |
|
269 | + $obj->{$field} = (string) $value[$i]; |
|
270 | + break; |
|
271 | + case 'integer': |
|
272 | + $obj->{$field} = (int) $value[$i]; |
|
273 | + break; |
|
274 | + case 'long': |
|
275 | + case 'double': |
|
276 | + $obj->{$field} = (float) $value[$i]; |
|
277 | + break; |
|
278 | + case 'null': |
|
279 | + $obj->{$field} = null; |
|
280 | + break; |
|
281 | + default: |
|
282 | + $obj->{$field} = $value[$i]; |
|
283 | + } |
|
284 | + } |
|
285 | + $iterator[] = $obj; |
|
286 | + } |
|
287 | + return $iterator; |
|
288 | + } |
|
289 | 289 | } |
290 | 290 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Response; |
16 | 16 | |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | $status = $response->getStatusCode(); |
67 | 67 | if ($throwException && $status > 399 && $status < 500) { |
68 | 68 | $error = new ClientResponseException( |
69 | - sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
69 | + sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string)$response->getBody()), |
|
70 | 70 | $status |
71 | 71 | ); |
72 | 72 | throw $error->setResponse($response); |
73 | 73 | } elseif ($throwException && $status > 499 && $status < 600) { |
74 | 74 | $error = new ServerResponseException( |
75 | - sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string) $response->getBody()), |
|
75 | + sprintf("%s %s: %s", $status, $response->getReasonPhrase(), (string)$response->getBody()), |
|
76 | 76 | $status |
77 | 77 | ); |
78 | 78 | throw $error->setResponse($response); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function asBool(): bool |
86 | 86 | { |
87 | - return $this->response->getStatusCode() >=200 && $this->response->getStatusCode() < 300; |
|
87 | + return $this->response->getStatusCode() >= 200 && $this->response->getStatusCode() < 300; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | public function asString(): string |
163 | 163 | { |
164 | 164 | if (empty($this->asString)) { |
165 | - $this->asString = (string) $this->response->getBody(); |
|
165 | + $this->asString = (string)$this->response->getBody(); |
|
166 | 166 | } |
167 | 167 | return $this->asString; |
168 | 168 | } |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | $ncol = count($response['columns']); |
251 | 251 | foreach ($response['values'] as $value) { |
252 | 252 | $obj = new $class; |
253 | - for ($i=0; $i < $ncol; $i++) { |
|
253 | + for ($i = 0; $i < $ncol; $i++) { |
|
254 | 254 | $field = Utility::formatVariableName($response['columns'][$i]['name']); |
255 | 255 | if ($class !== stdClass::class && !property_exists($obj, $field)) { |
256 | 256 | continue; |
257 | 257 | } |
258 | - switch($response['columns'][$i]['type']) { |
|
258 | + switch ($response['columns'][$i]['type']) { |
|
259 | 259 | case 'boolean': |
260 | - $obj->{$field} = (bool) $value[$i]; |
|
260 | + $obj->{$field} = (bool)$value[$i]; |
|
261 | 261 | break; |
262 | 262 | case 'date': |
263 | 263 | $obj->{$field} = new DateTime($value[$i]); |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | case 'text': |
267 | 267 | case 'keyword': |
268 | 268 | case 'ip': |
269 | - $obj->{$field} = (string) $value[$i]; |
|
269 | + $obj->{$field} = (string)$value[$i]; |
|
270 | 270 | break; |
271 | 271 | case 'integer': |
272 | - $obj->{$field} = (int) $value[$i]; |
|
272 | + $obj->{$field} = (int)$value[$i]; |
|
273 | 273 | break; |
274 | 274 | case 'long': |
275 | 275 | case 'double': |
276 | - $obj->{$field} = (float) $value[$i]; |
|
276 | + $obj->{$field} = (float)$value[$i]; |
|
277 | 277 | break; |
278 | 278 | case 'null': |
279 | 279 | $obj->{$field} = null; |
@@ -18,8 +18,8 @@ |
||
18 | 18 | |
19 | 19 | interface ElasticsearchInterface |
20 | 20 | { |
21 | - /** |
|
22 | - * Set the HTTP PSR-7 response |
|
23 | - */ |
|
24 | - public function setResponse(ResponseInterface $response, bool $throwException = true): void; |
|
21 | + /** |
|
22 | + * Set the HTTP PSR-7 response |
|
23 | + */ |
|
24 | + public function setResponse(ResponseInterface $response, bool $throwException = true): void; |
|
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * Elasticsearch B.V licenses this file to you under the MIT License. |
11 | 11 | * See the LICENSE file in the project root for more information. |
12 | 12 | */ |
13 | -declare(strict_types = 1); |
|
13 | +declare(strict_types=1); |
|
14 | 14 | |
15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Elasticsearch\Response; |
16 | 16 |
@@ -16,8 +16,7 @@ |
||
16 | 16 | |
17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
18 | 18 | |
19 | -interface ElasticsearchInterface |
|
20 | -{ |
|
19 | +interface ElasticsearchInterface { |
|
21 | 20 | /** |
22 | 21 | * Set the HTTP PSR-7 response |
23 | 22 | */ |