@@ -144,6 +144,9 @@ class ClientBuilder
144
144
*/
145
145
private $ includePortInHostHeader = false ;
146
146
147
+ /**
148
+ * Create an instance of ClientBuilder
149
+ */
147
150
public static function create (): ClientBuilder
148
151
{
149
152
return new static ();
@@ -185,6 +188,7 @@ public function getRegisteredNamespacesBuilders(): array
185
188
* Unknown keys will throw an exception by default, but this can be silenced
186
189
* by setting `quiet` to true
187
190
*
191
+ * @param array $config
188
192
* @param bool $quiet False if unknown settings throw exception, true to silently
189
193
* ignore unknown settings
190
194
* @throws Common\Exceptions\RuntimeException
@@ -214,6 +218,10 @@ public static function fromConfig(array $config, bool $quiet = false): Client
214
218
}
215
219
216
220
/**
221
+ * Get the default handler
222
+ *
223
+ * @param array $multiParams
224
+ * @param array $singleParams
217
225
* @throws \RuntimeException
218
226
*/
219
227
public static function defaultHandler (array $ multiParams = [], array $ singleParams = []): callable
@@ -235,6 +243,8 @@ public static function defaultHandler(array $multiParams = [], array $singlePara
235
243
}
236
244
237
245
/**
246
+ * Get the multi handler for async (CurlMultiHandler)
247
+ *
238
248
* @throws \RuntimeException
239
249
*/
240
250
public static function multiHandler (array $ params = []): CurlMultiHandler
@@ -247,6 +257,8 @@ public static function multiHandler(array $params = []): CurlMultiHandler
247
257
}
248
258
249
259
/**
260
+ * Get the handler instance (CurlHandler)
261
+ *
250
262
* @throws \RuntimeException
251
263
*/
252
264
public static function singleHandler (): CurlHandler
@@ -258,6 +270,11 @@ public static function singleHandler(): CurlHandler
258
270
}
259
271
}
260
272
273
+ /**
274
+ * Set connection Factory
275
+ *
276
+ * @param ConnectionFactoryInterface $connectionFactory
277
+ */
261
278
public function setConnectionFactory (ConnectionFactoryInterface $ connectionFactory ): ClientBuilder
262
279
{
263
280
$ this ->connectionFactory = $ connectionFactory ;
@@ -266,7 +283,10 @@ public function setConnectionFactory(ConnectionFactoryInterface $connectionFacto
266
283
}
267
284
268
285
/**
286
+ * Set the connection pool (default is StaticNoPingConnectionPool)
287
+ *
269
288
* @param AbstractConnectionPool|string $connectionPool
289
+ * @param array $args
270
290
* @throws \InvalidArgumentException
271
291
*/
272
292
public function setConnectionPool ($ connectionPool , array $ args = []): ClientBuilder
@@ -283,20 +303,35 @@ public function setConnectionPool($connectionPool, array $args = []): ClientBuil
283
303
return $ this ;
284
304
}
285
305
306
+ /**
307
+ * Set the endpoint
308
+ *
309
+ * @param callable $endpoint
310
+ */
286
311
public function setEndpoint (callable $ endpoint ): ClientBuilder
287
312
{
288
313
$ this ->endpoint = $ endpoint ;
289
314
290
315
return $ this ;
291
316
}
292
317
318
+ /**
319
+ * Register namespace
320
+ *
321
+ * @param NamespaceBuilderInterface $namespaceBuilder
322
+ */
293
323
public function registerNamespace (NamespaceBuilderInterface $ namespaceBuilder ): ClientBuilder
294
324
{
295
325
$ this ->registeredNamespacesBuilders [] = $ namespaceBuilder ;
296
326
297
327
return $ this ;
298
328
}
299
329
330
+ /**
331
+ * Set the transport
332
+ *
333
+ * @param Transport $transport
334
+ */
300
335
public function setTransport (Transport $ transport ): ClientBuilder
301
336
{
302
337
$ this ->transport = $ transport ;
@@ -305,8 +340,9 @@ public function setTransport(Transport $transport): ClientBuilder
305
340
}
306
341
307
342
/**
343
+ * Set the HTTP handler (cURL is default)
344
+ *
308
345
* @param mixed $handler
309
- * @return $this
310
346
*/
311
347
public function setHandler ($ handler ): ClientBuilder
312
348
{
@@ -315,13 +351,23 @@ public function setHandler($handler): ClientBuilder
315
351
return $ this ;
316
352
}
317
353
354
+ /**
355
+ * Set the PSR-3 Logger
356
+ *
357
+ * @param LoggerInterface $logger
358
+ */
318
359
public function setLogger (LoggerInterface $ logger ): ClientBuilder
319
360
{
320
361
$ this ->logger = $ logger ;
321
362
322
363
return $ this ;
323
364
}
324
365
366
+ /**
367
+ * Set the PSR-3 tracer
368
+ *
369
+ * @param LoggerInterface $tracer
370
+ */
325
371
public function setTracer (LoggerInterface $ tracer ): ClientBuilder
326
372
{
327
373
$ this ->tracer = $ tracer ;
@@ -330,6 +376,8 @@ public function setTracer(LoggerInterface $tracer): ClientBuilder
330
376
}
331
377
332
378
/**
379
+ * Set the serializer
380
+ *
333
381
* @param \Elasticsearch\Serializers\SerializerInterface|string $serializer
334
382
*/
335
383
public function setSerializer ($ serializer ): ClientBuilder
@@ -339,6 +387,11 @@ public function setSerializer($serializer): ClientBuilder
339
387
return $ this ;
340
388
}
341
389
390
+ /**
391
+ * Set the hosts (nodes)
392
+ *
393
+ * @param array $hosts
394
+ */
342
395
public function setHosts (array $ hosts ): ClientBuilder
343
396
{
344
397
$ this ->hosts = $ hosts ;
@@ -365,8 +418,9 @@ public function setApiKey(string $id, string $apiKey): ClientBuilder
365
418
}
366
419
367
420
/**
368
- * Set the APIKey Pair, consiting of the API Id and the ApiKey of the Response from /_security/api_key
421
+ * Set Basic access authentication
369
422
*
423
+ * @see https://en.wikipedia.org/wiki/Basic_access_authentication
370
424
* @param string $username
371
425
* @param string $password
372
426
*
@@ -416,13 +470,23 @@ public function setElasticCloudId(string $cloudId): ClientBuilder
416
470
return $ this ;
417
471
}
418
472
473
+ /**
474
+ * Set connection parameters
475
+ *
476
+ * @param array $params
477
+ */
419
478
public function setConnectionParams (array $ params ): ClientBuilder
420
479
{
421
480
$ this ->connectionParams = $ params ;
422
481
423
482
return $ this ;
424
483
}
425
484
485
+ /**
486
+ * Set number or retries (default is equal to number of nodes)
487
+ *
488
+ * @param int $retries
489
+ */
426
490
public function setRetries (int $ retries ): ClientBuilder
427
491
{
428
492
$ this ->retries = $ retries ;
@@ -431,6 +495,8 @@ public function setRetries(int $retries): ClientBuilder
431
495
}
432
496
433
497
/**
498
+ * Set the selector algorithm
499
+ *
434
500
* @param \Elasticsearch\ConnectionPool\Selectors\SelectorInterface|string $selector
435
501
*/
436
502
public function setSelector ($ selector ): ClientBuilder
@@ -440,6 +506,12 @@ public function setSelector($selector): ClientBuilder
440
506
return $ this ;
441
507
}
442
508
509
+ /**
510
+ * Set sniff on start
511
+ *
512
+ * @param bool $sniffOnStart enable or disable sniff on start
513
+ */
514
+
443
515
public function setSniffOnStart (bool $ sniffOnStart ): ClientBuilder
444
516
{
445
517
$ this ->sniffOnStart = $ sniffOnStart ;
@@ -448,7 +520,10 @@ public function setSniffOnStart(bool $sniffOnStart): ClientBuilder
448
520
}
449
521
450
522
/**
523
+ * Set SSL certificate
524
+ *
451
525
* @param string $cert The name of a file containing a PEM formatted certificate.
526
+ * @param string $password if the certificate requires a password
452
527
*/
453
528
public function setSSLCert (string $ cert , string $ password = null ): ClientBuilder
454
529
{
@@ -458,7 +533,10 @@ public function setSSLCert(string $cert, string $password = null): ClientBuilder
458
533
}
459
534
460
535
/**
461
- * @param string $key The name of a file containing a private SSL key.
536
+ * Set SSL key
537
+ *
538
+ * @param string $key The name of a file containing a private SSL key
539
+ * @param string $password if the private key requires a password
462
540
*/
463
541
public function setSSLKey (string $ key , string $ password = null ): ClientBuilder
464
542
{
@@ -468,6 +546,8 @@ public function setSSLKey(string $key, string $password = null): ClientBuilder
468
546
}
469
547
470
548
/**
549
+ * Set SSL verification
550
+ *
471
551
* @param bool|string $value
472
552
*/
473
553
public function setSSLVerification ($ value = true ): ClientBuilder
@@ -499,6 +579,9 @@ public function includePortInHostHeader(bool $enable): ClientBuilder
499
579
return $ this ;
500
580
}
501
581
582
+ /**
583
+ * Build and returns the Client object
584
+ */
502
585
public function build (): Client
503
586
{
504
587
$ this ->buildLoggers ();
0 commit comments