Completed
Pull Request — master (#359)
by Maxence
41s
created
lib/Vendor/Elastic/Elasticsearch/Traits/NamespaceTrait.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Traits/ResponseTrait.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,16 +18,16 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Traits/EndpointTrait.php 3 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -29,169 +29,169 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,7 @@
 block discarded – undo
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
      */
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Response/Elasticsearch.php 2 patches
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -35,255 +35,255 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Response/ElasticsearchInterface.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
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
      */
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/ClientInterface.php 3 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -22,51 +22,51 @@
 block discarded – undo
22 22
 
23 23
 interface ClientInterface
24 24
 {
25
-    /**
26
-     * Get the OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Transport
27
-     */
28
-    public function getTransport(): Transport;
25
+	/**
26
+	 * Get the OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Transport
27
+	 */
28
+	public function getTransport(): Transport;
29 29
 
30
-    /**
31
-     * Get the PSR-3 logger
32
-     */
33
-    public function getLogger(): LoggerInterface;
30
+	/**
31
+	 * Get the PSR-3 logger
32
+	 */
33
+	public function getLogger(): LoggerInterface;
34 34
 
35
-     /**
36
-     * Set the asyncronous HTTP request
37
-     */
38
-    public function setAsync(bool $async): self;
35
+	 /**
36
+	  * Set the asyncronous HTTP request
37
+	  */
38
+	public function setAsync(bool $async): self;
39 39
 
40
-    /**
41
-     * Get the asyncronous HTTP request setting
42
-     */
43
-    public function getAsync(): bool;
40
+	/**
41
+	 * Get the asyncronous HTTP request setting
42
+	 */
43
+	public function getAsync(): bool;
44 44
 
45
-    /**
46
-     * Enable or disable the x-elastic-client-meta header
47
-     */
48
-    public function setElasticMetaHeader(bool $active): self;
45
+	/**
46
+	 * Enable or disable the x-elastic-client-meta header
47
+	 */
48
+	public function setElasticMetaHeader(bool $active): self;
49 49
 
50
-    /**
51
-     * Get the status of x-elastic-client-meta header
52
-     */
53
-    public function getElasticMetaHeader(): bool;
50
+	/**
51
+	 * Get the status of x-elastic-client-meta header
52
+	 */
53
+	public function getElasticMetaHeader(): bool;
54 54
 
55
-     /**
56
-     * Enable or disable the response Exception
57
-     */
58
-    public function setResponseException(bool $active): self;
55
+	 /**
56
+	  * Enable or disable the response Exception
57
+	  */
58
+	public function setResponseException(bool $active): self;
59 59
 
60
-     /**
61
-     * Get the status of response Exception
62
-     */
63
-    public function getResponseException(): bool;
60
+	 /**
61
+	  * Get the status of response Exception
62
+	  */
63
+	public function getResponseException(): bool;
64 64
 
65
-    /**
66
-     * Send the HTTP request using the Elastic Transport.
67
-     * It manages syncronous and asyncronus requests using Client::getAsync()
68
-     * 
69
-     * @return Elasticsearch|Promise
70
-     */
71
-    public function sendRequest(RequestInterface $request);
65
+	/**
66
+	 * Send the HTTP request using the Elastic Transport.
67
+	 * It manages syncronous and asyncronus requests using Client::getAsync()
68
+	 * 
69
+	 * @return Elasticsearch|Promise
70
+	 */
71
+	public function sendRequest(RequestInterface $request);
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
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;
16 16
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
20 20
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface;
21 21
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\LoggerInterface;
22 22
 
23
-interface ClientInterface
24
-{
23
+interface ClientInterface {
25 24
     /**
26 25
      * Get the OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Transport
27 26
      */
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/ClientBuilder.php 3 patches
Indentation   +434 added lines, -434 removed lines patch added patch discarded remove patch
@@ -33,440 +33,440 @@
 block discarded – undo
33 33
 
34 34
 class ClientBuilder
35 35
 {
36
-    const DEFAULT_HOST = 'localhost:9200';
37
-
38
-    /**
39
-     * PSR-18 client
40
-     */
41
-    private ClientInterface $httpClient;
42
-
43
-    /**
44
-     * The HTTP async client
45
-     */
46
-    private HttpAsyncClient $asyncHttpClient;
47
-
48
-    /**
49
-     * PSR-3 Logger
50
-     */
51
-    private LoggerInterface $logger;
52
-
53
-    /**
54
-     * The NodelPool
55
-     */
56
-    private NodePoolInterface $nodePool;
57
-
58
-    /**
59
-     * Hosts (elasticsearch nodes)
60
-     */
61
-    private array $hosts;
62
-
63
-    /**
64
-     * Elasticsearch API key
65
-     */
66
-    private string $apiKey;
67
-
68
-    /**
69
-     * Basic authentication username
70
-     */
71
-    private string $username;
72
-
73
-    /**
74
-     * Basic authentication password
75
-     */
76
-    private string $password;
77
-
78
-    /**
79
-     * Elastic cloud Id
80
-     */
81
-    private string $cloudId;
82
-
83
-    /**
84
-     * Retries
85
-     * 
86
-     * The default value is calculated during the client build
87
-     * and it is equal to the number of hosts
88
-     */
89
-    private int $retries;
90
-
91
-    /**
92
-     * SSL certificate 
93
-     * @var array [$cert, $password] $cert is the name of a file containing a PEM formatted certificate,
94
-     *              $password if the certificate requires a password 
95
-     */
96
-    private array $sslCert;
97
-
98
-    /**
99
-     * SSL key
100
-     * @var array [$key, $password] $key is the name of a file containing a private SSL key,
101
-     *              $password if the private key requires a password
102
-     */
103
-    private array $sslKey;
104
-
105
-    /**
106
-     * SSL verification
107
-     * 
108
-     * Enable or disable the SSL verfiication (default is true)
109
-     */
110
-    private bool $sslVerification = true;
111
-
112
-    /**
113
-     * SSL CA bundle
114
-     */
115
-    private string $sslCA;
116
-
117
-    /**
118
-     * Elastic meta header
119
-     * 
120
-     * Enable or disable the x-elastic-client-meta header (default is true)
121
-     */
122
-    private bool $elasticMetaHeader = true;
123
-
124
-    /**
125
-     * HTTP client options
126
-     */
127
-    private array $httpClientOptions = [];
128
-
129
-    /**
130
-     * Make the constructor final so cannot be overwritten
131
-     */
132
-    final public function __construct()
133
-    {
134
-    }
135
-
136
-    /**
137
-     * Create an instance of ClientBuilder
138
-     */
139
-    public static function create(): ClientBuilder
140
-    {
141
-        return new static();
142
-    }
143
-
144
-    /**
145
-     * Build a new client from the provided config.  Hash keys
146
-     * should correspond to the method name e.g. ['nodePool']
147
-     * corresponds to setNodePool().
148
-     *
149
-     * Missing keys will use the default for that setting if applicable
150
-     *
151
-     * Unknown keys will throw an exception by default, but this can be silenced
152
-     * by setting `quiet` to true
153
-     *
154
-     * @param  array $config
155
-     * @param  bool $quiet False if unknown settings throw exception, true to silently
156
-     *                     ignore unknown settings
157
-     * @throws ConfigException
158
-     */
159
-    public static function fromConfig(array $config, bool $quiet = false): Client
160
-    {
161
-        $builder = new static;
162
-        foreach ($config as $key => $value) {
163
-            $method = "set$key";
164
-            $reflection = new ReflectionClass($builder);
165
-            if ($reflection->hasMethod($method)) {
166
-                $func = $reflection->getMethod($method);
167
-                if ($func->getNumberOfParameters() > 1) {
168
-                    $builder->$method(...$value);
169
-                } else {
170
-                    $builder->$method($value);
171
-                }
172
-                unset($config[$key]);
173
-            }
174
-        }
175
-
176
-        if ($quiet === false && count($config) > 0) {
177
-            $unknown = implode(array_keys($config));
178
-            throw new ConfigException("Unknown parameters provided: $unknown");
179
-        }
180
-        return $builder->build();
181
-    }
182
-
183
-    public function setHttpClient(ClientInterface $httpClient): ClientBuilder
184
-    {
185
-        $this->httpClient = $httpClient;
186
-        return $this;
187
-    }
188
-
189
-    public function setAsyncHttpClient(HttpAsyncClient $asyncHttpClient): ClientBuilder
190
-    {
191
-        $this->asyncHttpClient = $asyncHttpClient;
192
-        return $this;
193
-    }
194
-
195
-    /**
196
-     * Set the PSR-3 Logger
197
-     */
198
-    public function setLogger(LoggerInterface $logger): ClientBuilder
199
-    {
200
-        $this->logger = $logger;
201
-        return $this;
202
-    }
203
-
204
-    /**
205
-     * Set the NodePool
206
-     */
207
-    public function setNodePool(NodePoolInterface $nodePool): ClientBuilder
208
-    {
209
-        $this->nodePool = $nodePool;
210
-        return $this;
211
-    }
212
-
213
-    /**
214
-     * Set the hosts (nodes)
215
-     */
216
-    public function setHosts(array $hosts): ClientBuilder
217
-    {
218
-        $this->hosts = $hosts;
219
-        return $this;
220
-    }
221
-
222
-    /**
223
-     * Set the ApiKey
224
-     * If the id is not specified we store the ApiKey otherwise
225
-     * we store as Base64(id:ApiKey)
226
-     *
227
-     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
228
-     */
229
-    public function setApiKey(string $apiKey, string $id = null): ClientBuilder
230
-    {
231
-        if (empty($id)) {
232
-            $this->apiKey = $apiKey;
233
-        } else {
234
-            $this->apiKey = base64_encode($id . ':' . $apiKey);
235
-        }
236
-        return $this;
237
-    }
238
-
239
-    /**
240
-     * Set the Basic Authentication
241
-     */
242
-    public function setBasicAuthentication(string $username, string $password): ClientBuilder
243
-    {
244
-        $this->username = $username;
245
-        $this->password = $password;
246
-        return $this;
247
-    }
248
-
249
-    public function setElasticCloudId(string $cloudId)
250
-    {
251
-        $this->cloudId = $cloudId;
252
-        return $this;
253
-    }
254
-
255
-    /**
256
-     * Set number or retries
257
-     * 
258
-     * @param int $retries
259
-     */
260
-    public function setRetries(int $retries): ClientBuilder
261
-    {
262
-        if ($retries < 0) {
263
-            throw new InvalidArgumentException('The retries number must be >= 0');
264
-        }
265
-        $this->retries = $retries;
266
-        return $this;
267
-    }
268
-
269
-    /**
270
-     * Set SSL certificate
271
-     * 
272
-     * @param string $cert The name of a file containing a PEM formatted certificate
273
-     * @param string $password if the certificate requires a password
274
-     */
275
-    public function setSSLCert(string $cert, string $password = null): ClientBuilder
276
-    {
277
-        $this->sslCert = [$cert, $password];
278
-        return $this;
279
-    }
280
-
281
-    /**
282
-     * Set the Certificate Authority (CA) bundle 
283
-     * 
284
-     * @param string $cert The name of a file containing a PEM formatted certificate
285
-     */
286
-    public function setCABundle(string $cert): ClientBuilder
287
-    {
288
-        $this->sslCA = $cert;
289
-        return $this;
290
-    }
291
-
292
-    /**
293
-     * Set SSL key
294
-     * 
295
-     * @param string $key The name of a file containing a private SSL key
296
-     * @param string $password if the private key requires a password
297
-     */
298
-    public function setSSLKey(string $key, string $password = null): ClientBuilder
299
-    {
300
-        $this->sslKey = [$key, $password];
301
-        return $this;
302
-    }
303
-
304
-    /**
305
-     * Enable or disable the SSL verification 
306
-     */
307
-    public function setSSLVerification(bool $value = true): ClientBuilder
308
-    {
309
-        $this->sslVerification = $value;
310
-        return $this;
311
-    }
312
-
313
-    /**
314
-     * Enable or disable the x-elastic-client-meta header
315
-     */
316
-    public function setElasticMetaHeader(bool $value = true): ClientBuilder
317
-    {
318
-        $this->elasticMetaHeader = $value;
319
-        return $this;
320
-    }
321
-
322
-    public function setHttpClientOptions(array $options): ClientBuilder
323
-    {
324
-        $this->httpClientOptions = $options;
325
-        return $this;
326
-    }
327
-
328
-    /**
329
-     * Build and returns the Client object
330
-     */
331
-    public function build(): Client
332
-    {
333
-        // Transport builder
334
-        $builder = TransportBuilder::create();
335
-
336
-        // Set the default hosts if empty
337
-        if (empty($this->hosts)) {
338
-            $this->hosts = [self::DEFAULT_HOST];
339
-        }
340
-        $builder->setHosts($this->hosts);
341
-
342
-        // Logger
343
-        if (!empty($this->logger)) {    
344
-            $builder->setLogger($this->logger);
345
-        }
346
-
347
-        // Http client
348
-        if (!empty($this->httpClient)) {
349
-            $builder->setClient($this->httpClient);
350
-        }
351
-        // Set HTTP client options
352
-        $builder->setClient(
353
-            $this->setOptions($builder->getClient(), $this->getConfig(), $this->httpClientOptions)
354
-        );
355
-
356
-        // Cloud id
357
-        if (!empty($this->cloudId)) {
358
-            $builder->setCloudId($this->cloudId);
359
-        }
360
-
361
-        // Node Pool
362
-        if (!empty($this->nodePool)) {
363
-            $builder->setNodePool($this->nodePool);
364
-        }
365
-
366
-        $transport = $builder->build();
36
+	const DEFAULT_HOST = 'localhost:9200';
37
+
38
+	/**
39
+	 * PSR-18 client
40
+	 */
41
+	private ClientInterface $httpClient;
42
+
43
+	/**
44
+	 * The HTTP async client
45
+	 */
46
+	private HttpAsyncClient $asyncHttpClient;
47
+
48
+	/**
49
+	 * PSR-3 Logger
50
+	 */
51
+	private LoggerInterface $logger;
52
+
53
+	/**
54
+	 * The NodelPool
55
+	 */
56
+	private NodePoolInterface $nodePool;
57
+
58
+	/**
59
+	 * Hosts (elasticsearch nodes)
60
+	 */
61
+	private array $hosts;
62
+
63
+	/**
64
+	 * Elasticsearch API key
65
+	 */
66
+	private string $apiKey;
67
+
68
+	/**
69
+	 * Basic authentication username
70
+	 */
71
+	private string $username;
72
+
73
+	/**
74
+	 * Basic authentication password
75
+	 */
76
+	private string $password;
77
+
78
+	/**
79
+	 * Elastic cloud Id
80
+	 */
81
+	private string $cloudId;
82
+
83
+	/**
84
+	 * Retries
85
+	 * 
86
+	 * The default value is calculated during the client build
87
+	 * and it is equal to the number of hosts
88
+	 */
89
+	private int $retries;
90
+
91
+	/**
92
+	 * SSL certificate 
93
+	 * @var array [$cert, $password] $cert is the name of a file containing a PEM formatted certificate,
94
+	 *              $password if the certificate requires a password 
95
+	 */
96
+	private array $sslCert;
97
+
98
+	/**
99
+	 * SSL key
100
+	 * @var array [$key, $password] $key is the name of a file containing a private SSL key,
101
+	 *              $password if the private key requires a password
102
+	 */
103
+	private array $sslKey;
104
+
105
+	/**
106
+	 * SSL verification
107
+	 * 
108
+	 * Enable or disable the SSL verfiication (default is true)
109
+	 */
110
+	private bool $sslVerification = true;
111
+
112
+	/**
113
+	 * SSL CA bundle
114
+	 */
115
+	private string $sslCA;
116
+
117
+	/**
118
+	 * Elastic meta header
119
+	 * 
120
+	 * Enable or disable the x-elastic-client-meta header (default is true)
121
+	 */
122
+	private bool $elasticMetaHeader = true;
123
+
124
+	/**
125
+	 * HTTP client options
126
+	 */
127
+	private array $httpClientOptions = [];
128
+
129
+	/**
130
+	 * Make the constructor final so cannot be overwritten
131
+	 */
132
+	final public function __construct()
133
+	{
134
+	}
135
+
136
+	/**
137
+	 * Create an instance of ClientBuilder
138
+	 */
139
+	public static function create(): ClientBuilder
140
+	{
141
+		return new static();
142
+	}
143
+
144
+	/**
145
+	 * Build a new client from the provided config.  Hash keys
146
+	 * should correspond to the method name e.g. ['nodePool']
147
+	 * corresponds to setNodePool().
148
+	 *
149
+	 * Missing keys will use the default for that setting if applicable
150
+	 *
151
+	 * Unknown keys will throw an exception by default, but this can be silenced
152
+	 * by setting `quiet` to true
153
+	 *
154
+	 * @param  array $config
155
+	 * @param  bool $quiet False if unknown settings throw exception, true to silently
156
+	 *                     ignore unknown settings
157
+	 * @throws ConfigException
158
+	 */
159
+	public static function fromConfig(array $config, bool $quiet = false): Client
160
+	{
161
+		$builder = new static;
162
+		foreach ($config as $key => $value) {
163
+			$method = "set$key";
164
+			$reflection = new ReflectionClass($builder);
165
+			if ($reflection->hasMethod($method)) {
166
+				$func = $reflection->getMethod($method);
167
+				if ($func->getNumberOfParameters() > 1) {
168
+					$builder->$method(...$value);
169
+				} else {
170
+					$builder->$method($value);
171
+				}
172
+				unset($config[$key]);
173
+			}
174
+		}
175
+
176
+		if ($quiet === false && count($config) > 0) {
177
+			$unknown = implode(array_keys($config));
178
+			throw new ConfigException("Unknown parameters provided: $unknown");
179
+		}
180
+		return $builder->build();
181
+	}
182
+
183
+	public function setHttpClient(ClientInterface $httpClient): ClientBuilder
184
+	{
185
+		$this->httpClient = $httpClient;
186
+		return $this;
187
+	}
188
+
189
+	public function setAsyncHttpClient(HttpAsyncClient $asyncHttpClient): ClientBuilder
190
+	{
191
+		$this->asyncHttpClient = $asyncHttpClient;
192
+		return $this;
193
+	}
194
+
195
+	/**
196
+	 * Set the PSR-3 Logger
197
+	 */
198
+	public function setLogger(LoggerInterface $logger): ClientBuilder
199
+	{
200
+		$this->logger = $logger;
201
+		return $this;
202
+	}
203
+
204
+	/**
205
+	 * Set the NodePool
206
+	 */
207
+	public function setNodePool(NodePoolInterface $nodePool): ClientBuilder
208
+	{
209
+		$this->nodePool = $nodePool;
210
+		return $this;
211
+	}
212
+
213
+	/**
214
+	 * Set the hosts (nodes)
215
+	 */
216
+	public function setHosts(array $hosts): ClientBuilder
217
+	{
218
+		$this->hosts = $hosts;
219
+		return $this;
220
+	}
221
+
222
+	/**
223
+	 * Set the ApiKey
224
+	 * If the id is not specified we store the ApiKey otherwise
225
+	 * we store as Base64(id:ApiKey)
226
+	 *
227
+	 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html
228
+	 */
229
+	public function setApiKey(string $apiKey, string $id = null): ClientBuilder
230
+	{
231
+		if (empty($id)) {
232
+			$this->apiKey = $apiKey;
233
+		} else {
234
+			$this->apiKey = base64_encode($id . ':' . $apiKey);
235
+		}
236
+		return $this;
237
+	}
238
+
239
+	/**
240
+	 * Set the Basic Authentication
241
+	 */
242
+	public function setBasicAuthentication(string $username, string $password): ClientBuilder
243
+	{
244
+		$this->username = $username;
245
+		$this->password = $password;
246
+		return $this;
247
+	}
248
+
249
+	public function setElasticCloudId(string $cloudId)
250
+	{
251
+		$this->cloudId = $cloudId;
252
+		return $this;
253
+	}
254
+
255
+	/**
256
+	 * Set number or retries
257
+	 * 
258
+	 * @param int $retries
259
+	 */
260
+	public function setRetries(int $retries): ClientBuilder
261
+	{
262
+		if ($retries < 0) {
263
+			throw new InvalidArgumentException('The retries number must be >= 0');
264
+		}
265
+		$this->retries = $retries;
266
+		return $this;
267
+	}
268
+
269
+	/**
270
+	 * Set SSL certificate
271
+	 * 
272
+	 * @param string $cert The name of a file containing a PEM formatted certificate
273
+	 * @param string $password if the certificate requires a password
274
+	 */
275
+	public function setSSLCert(string $cert, string $password = null): ClientBuilder
276
+	{
277
+		$this->sslCert = [$cert, $password];
278
+		return $this;
279
+	}
280
+
281
+	/**
282
+	 * Set the Certificate Authority (CA) bundle 
283
+	 * 
284
+	 * @param string $cert The name of a file containing a PEM formatted certificate
285
+	 */
286
+	public function setCABundle(string $cert): ClientBuilder
287
+	{
288
+		$this->sslCA = $cert;
289
+		return $this;
290
+	}
291
+
292
+	/**
293
+	 * Set SSL key
294
+	 * 
295
+	 * @param string $key The name of a file containing a private SSL key
296
+	 * @param string $password if the private key requires a password
297
+	 */
298
+	public function setSSLKey(string $key, string $password = null): ClientBuilder
299
+	{
300
+		$this->sslKey = [$key, $password];
301
+		return $this;
302
+	}
303
+
304
+	/**
305
+	 * Enable or disable the SSL verification 
306
+	 */
307
+	public function setSSLVerification(bool $value = true): ClientBuilder
308
+	{
309
+		$this->sslVerification = $value;
310
+		return $this;
311
+	}
312
+
313
+	/**
314
+	 * Enable or disable the x-elastic-client-meta header
315
+	 */
316
+	public function setElasticMetaHeader(bool $value = true): ClientBuilder
317
+	{
318
+		$this->elasticMetaHeader = $value;
319
+		return $this;
320
+	}
321
+
322
+	public function setHttpClientOptions(array $options): ClientBuilder
323
+	{
324
+		$this->httpClientOptions = $options;
325
+		return $this;
326
+	}
327
+
328
+	/**
329
+	 * Build and returns the Client object
330
+	 */
331
+	public function build(): Client
332
+	{
333
+		// Transport builder
334
+		$builder = TransportBuilder::create();
335
+
336
+		// Set the default hosts if empty
337
+		if (empty($this->hosts)) {
338
+			$this->hosts = [self::DEFAULT_HOST];
339
+		}
340
+		$builder->setHosts($this->hosts);
341
+
342
+		// Logger
343
+		if (!empty($this->logger)) {    
344
+			$builder->setLogger($this->logger);
345
+		}
346
+
347
+		// Http client
348
+		if (!empty($this->httpClient)) {
349
+			$builder->setClient($this->httpClient);
350
+		}
351
+		// Set HTTP client options
352
+		$builder->setClient(
353
+			$this->setOptions($builder->getClient(), $this->getConfig(), $this->httpClientOptions)
354
+		);
355
+
356
+		// Cloud id
357
+		if (!empty($this->cloudId)) {
358
+			$builder->setCloudId($this->cloudId);
359
+		}
360
+
361
+		// Node Pool
362
+		if (!empty($this->nodePool)) {
363
+			$builder->setNodePool($this->nodePool);
364
+		}
365
+
366
+		$transport = $builder->build();
367 367
         
368
-        // The default retries is equal to the number of hosts
369
-        if (empty($this->retries)) {
370
-            $this->retries = count($this->hosts);
371
-        }
372
-        $transport->setRetries($this->retries);
373
-
374
-        // Async client
375
-        if (!empty($this->asyncHttpClient)) {
376
-            $transport->setAsyncClient($this->asyncHttpClient);
377
-        }
368
+		// The default retries is equal to the number of hosts
369
+		if (empty($this->retries)) {
370
+			$this->retries = count($this->hosts);
371
+		}
372
+		$transport->setRetries($this->retries);
373
+
374
+		// Async client
375
+		if (!empty($this->asyncHttpClient)) {
376
+			$transport->setAsyncClient($this->asyncHttpClient);
377
+		}
378 378
         
379
-        // Basic authentication
380
-        if (!empty($this->username) && !empty($this->password)) {
381
-            $transport->setUserInfo($this->username, $this->password);
382
-        }
383
-
384
-        // API key
385
-        if (!empty($this->apiKey)) {
386
-            if (!empty($this->username)) {
387
-                throw new AuthenticationException('You cannot use APIKey and Basic Authenication together');
388
-            }
389
-            $transport->setHeader('Authorization', sprintf("ApiKey %s", $this->apiKey));
390
-        }
391
-
392
-        /**
393
-         * Elastic cloud optimized with gzip
394
-         * @see https://github.com/elastic/elasticsearch-php/issues/1241 omit for Symfony HTTP Client    
395
-         */
396
-        if (!empty($this->cloudId) && !$this->isSymfonyHttpClient($transport)) {
397
-            $transport->setHeader('Accept-Encoding', 'gzip');
398
-        }
399
-
400
-        $client = new Client($transport, $transport->getLogger());
401
-        // Enable or disable the x-elastic-client-meta header
402
-        $client->setElasticMetaHeader($this->elasticMetaHeader);
403
-
404
-        return $client;
405
-    }
406
-
407
-    /**
408
-     * Returns true if the transport HTTP client is Symfony
409
-     */
410
-    protected function isSymfonyHttpClient(Transport $transport): bool
411
-    {
412
-        if (false !== strpos(get_class($transport->getClient()), 'Symfony\Component\HttpClient')) {
413
-            return true;
414
-        }
415
-        try {
416
-            if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) {
417
-                return true;
418
-            }
419
-        } catch (NoAsyncClientException $e) {
420
-            return false;
421
-        }
422
-        return false;
423
-    }
424
-
425
-    /**
426
-     * Returns the configuration to be used in the HTTP client
427
-     */
428
-    protected function getConfig(): array
429
-    {
430
-        $config = [];
431
-        if (!empty($this->sslCert)) {
432
-            $config[RequestOptions::SSL_CERT] = $this->sslCert;
433
-        }
434
-        if (!empty($this->sslKey)) {
435
-            $config[RequestOptions::SSL_KEY] = $this->sslKey;
436
-        }
437
-        if (!$this->sslVerification) {
438
-            $config[RequestOptions::SSL_VERIFY] = false;
439
-        }
440
-        if (!empty($this->sslCA)) {
441
-            $config[RequestOptions::SSL_CA] = $this->sslCA;
442
-        }
443
-        return $config;
444
-    }
445
-
446
-    /**
447
-     * Set the configuration for the specific HTTP client using an adapter
448
-     */
449
-    protected function setOptions(ClientInterface $client, array $config, array $clientOptions = []): ClientInterface
450
-    {
451
-        if (empty($config) && empty($clientOptions)) {
452
-            return $client;
453
-        }
454
-        $class = get_class($client);
455
-        if (!isset(AdapterOptions::HTTP_ADAPTERS[$class])) {
456
-            throw new HttpClientException(sprintf(
457
-                "The HTTP client %s is not supported for custom options",
458
-                $class
459
-            ));
460
-        }
461
-        $adapterClass = AdapterOptions::HTTP_ADAPTERS[$class];
462
-        if (!class_exists($adapterClass) || !in_array(AdapterInterface::class, class_implements($adapterClass))) {
463
-            throw new HttpClientException(sprintf(
464
-                "The class %s does not exists or does not implement %s",
465
-                $adapterClass,
466
-                AdapterInterface::class
467
-            ));
468
-        }
469
-        $adapter = new $adapterClass;
470
-        return $adapter->setConfig($client, $config, $clientOptions);
471
-    }
379
+		// Basic authentication
380
+		if (!empty($this->username) && !empty($this->password)) {
381
+			$transport->setUserInfo($this->username, $this->password);
382
+		}
383
+
384
+		// API key
385
+		if (!empty($this->apiKey)) {
386
+			if (!empty($this->username)) {
387
+				throw new AuthenticationException('You cannot use APIKey and Basic Authenication together');
388
+			}
389
+			$transport->setHeader('Authorization', sprintf("ApiKey %s", $this->apiKey));
390
+		}
391
+
392
+		/**
393
+		 * Elastic cloud optimized with gzip
394
+		 * @see https://github.com/elastic/elasticsearch-php/issues/1241 omit for Symfony HTTP Client    
395
+		 */
396
+		if (!empty($this->cloudId) && !$this->isSymfonyHttpClient($transport)) {
397
+			$transport->setHeader('Accept-Encoding', 'gzip');
398
+		}
399
+
400
+		$client = new Client($transport, $transport->getLogger());
401
+		// Enable or disable the x-elastic-client-meta header
402
+		$client->setElasticMetaHeader($this->elasticMetaHeader);
403
+
404
+		return $client;
405
+	}
406
+
407
+	/**
408
+	 * Returns true if the transport HTTP client is Symfony
409
+	 */
410
+	protected function isSymfonyHttpClient(Transport $transport): bool
411
+	{
412
+		if (false !== strpos(get_class($transport->getClient()), 'Symfony\Component\HttpClient')) {
413
+			return true;
414
+		}
415
+		try {
416
+			if (false !== strpos(get_class($transport->getAsyncClient()), 'Symfony\Component\HttpClient')) {
417
+				return true;
418
+			}
419
+		} catch (NoAsyncClientException $e) {
420
+			return false;
421
+		}
422
+		return false;
423
+	}
424
+
425
+	/**
426
+	 * Returns the configuration to be used in the HTTP client
427
+	 */
428
+	protected function getConfig(): array
429
+	{
430
+		$config = [];
431
+		if (!empty($this->sslCert)) {
432
+			$config[RequestOptions::SSL_CERT] = $this->sslCert;
433
+		}
434
+		if (!empty($this->sslKey)) {
435
+			$config[RequestOptions::SSL_KEY] = $this->sslKey;
436
+		}
437
+		if (!$this->sslVerification) {
438
+			$config[RequestOptions::SSL_VERIFY] = false;
439
+		}
440
+		if (!empty($this->sslCA)) {
441
+			$config[RequestOptions::SSL_CA] = $this->sslCA;
442
+		}
443
+		return $config;
444
+	}
445
+
446
+	/**
447
+	 * Set the configuration for the specific HTTP client using an adapter
448
+	 */
449
+	protected function setOptions(ClientInterface $client, array $config, array $clientOptions = []): ClientInterface
450
+	{
451
+		if (empty($config) && empty($clientOptions)) {
452
+			return $client;
453
+		}
454
+		$class = get_class($client);
455
+		if (!isset(AdapterOptions::HTTP_ADAPTERS[$class])) {
456
+			throw new HttpClientException(sprintf(
457
+				"The HTTP client %s is not supported for custom options",
458
+				$class
459
+			));
460
+		}
461
+		$adapterClass = AdapterOptions::HTTP_ADAPTERS[$class];
462
+		if (!class_exists($adapterClass) || !in_array(AdapterInterface::class, class_implements($adapterClass))) {
463
+			throw new HttpClientException(sprintf(
464
+				"The class %s does not exists or does not implement %s",
465
+				$adapterClass,
466
+				AdapterInterface::class
467
+			));
468
+		}
469
+		$adapter = new $adapterClass;
470
+		return $adapter->setConfig($client, $config, $clientOptions);
471
+	}
472 472
 }
473 473
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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;
16 16
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         if (empty($id)) {
232 232
             $this->apiKey = $apiKey;
233 233
         } else {
234
-            $this->apiKey = base64_encode($id . ':' . $apiKey);
234
+            $this->apiKey = base64_encode($id.':'.$apiKey);
235 235
         }
236 236
         return $this;
237 237
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@
 block discarded – undo
31 31
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Log\LoggerInterface;
32 32
 use ReflectionClass;
33 33
 
34
-class ClientBuilder
35
-{
34
+class ClientBuilder {
36 35
     const DEFAULT_HOST = 'localhost:9200';
37 36
 
38 37
     /**
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Endpoints/AsyncSearch.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	public function delete(array $params = [])
53 53
 	{
54 54
 		$this->checkRequiredParameters(['id'], $params);
55
-		$url = '/_async_search/' . $this->encode($params['id']);
55
+		$url = '/_async_search/'.$this->encode($params['id']);
56 56
 		$method = 'DELETE';
57 57
 
58
-		$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
58
+		$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
59 59
 		$headers = [
60 60
 			'Accept' => 'application/json',
61 61
 		];
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	public function get(array $params = [])
91 91
 	{
92 92
 		$this->checkRequiredParameters(['id'], $params);
93
-		$url = '/_async_search/' . $this->encode($params['id']);
93
+		$url = '/_async_search/'.$this->encode($params['id']);
94 94
 		$method = 'GET';
95 95
 
96
-		$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_alive','typed_keys','pretty','human','error_trace','source','filter_path']);
96
+		$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout', 'keep_alive', 'typed_keys', 'pretty', 'human', 'error_trace', 'source', 'filter_path']);
97 97
 		$headers = [
98 98
 			'Accept' => 'application/json',
99 99
 		];
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	public function status(array $params = [])
127 127
 	{
128 128
 		$this->checkRequiredParameters(['id'], $params);
129
-		$url = '/_async_search/status/' . $this->encode($params['id']);
129
+		$url = '/_async_search/status/'.$this->encode($params['id']);
130 130
 		$method = 'GET';
131 131
 
132
-		$url = $this->addQueryString($url, $params, ['keep_alive','pretty','human','error_trace','source','filter_path']);
132
+		$url = $this->addQueryString($url, $params, ['keep_alive', 'pretty', 'human', 'error_trace', 'source', 'filter_path']);
133 133
 		$headers = [
134 134
 			'Accept' => 'application/json',
135 135
 		];
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 	public function submit(array $params = [])
203 203
 	{
204 204
 		if (isset($params['index'])) {
205
-			$url = '/' . $this->encode($params['index']) . '/_async_search';
205
+			$url = '/'.$this->encode($params['index']).'/_async_search';
206 206
 			$method = 'POST';
207 207
 		} else {
208 208
 			$url = '/_async_search';
209 209
 			$method = 'POST';
210 210
 		}
211
-		$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout','keep_on_completion','keep_alive','batched_reduce_size','request_cache','analyzer','analyze_wildcard','default_operator','df','explain','stored_fields','docvalue_fields','from','ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','lenient','preference','q','routing','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','max_concurrent_shard_requests','pretty','human','error_trace','source','filter_path']);
211
+		$url = $this->addQueryString($url, $params, ['wait_for_completion_timeout', 'keep_on_completion', 'keep_alive', 'batched_reduce_size', 'request_cache', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', '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', 'max_concurrent_shard_requests', 'pretty', 'human', 'error_trace', 'source', 'filter_path']);
212 212
 		$headers = [
213 213
 			'Accept' => 'application/json',
214 214
 			'Content-Type' => 'application/json',
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
 /**
27 27
  * @generated This file is generated, please do not edit
28 28
  */
29
-class AsyncSearch extends AbstractEndpoint
30
-{
29
+class AsyncSearch extends AbstractEndpoint {
31 30
 	/**
32 31
 	 * Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted.
33 32
 	 *
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Elasticsearch/Endpoints/Ssl.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 		$url = '/_ssl/certificates';
53 53
 		$method = 'GET';
54 54
 
55
-		$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
55
+		$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
56 56
 		$headers = [
57 57
 			'Accept' => 'application/json',
58 58
 		];
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,7 @@
 block discarded – undo
26 26
 /**
27 27
  * @generated This file is generated, please do not edit
28 28
  */
29
-class Ssl extends AbstractEndpoint
30
-{
29
+class Ssl extends AbstractEndpoint {
31 30
 	/**
32 31
 	 * Retrieves information about the X.509 certificates used to encrypt communications in the cluster.
33 32
 	 *
Please login to merge, or discard this patch.