Skip to content

Commit 7324ccd

Browse files
committed
Improved the phpdoc of ClientBuilder
1 parent 62711c6 commit 7324ccd

File tree

1 file changed

+89
-3
lines changed

1 file changed

+89
-3
lines changed

src/Elasticsearch/ClientBuilder.php

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class ClientBuilder
144144
*/
145145
private $includePortInHostHeader = false;
146146

147+
/**
148+
* Create an instance of ClientBuilder
149+
*/
147150
public static function create(): ClientBuilder
148151
{
149152
return new static();
@@ -185,6 +188,7 @@ public function getRegisteredNamespacesBuilders(): array
185188
* Unknown keys will throw an exception by default, but this can be silenced
186189
* by setting `quiet` to true
187190
*
191+
* @param array $config
188192
* @param bool $quiet False if unknown settings throw exception, true to silently
189193
* ignore unknown settings
190194
* @throws Common\Exceptions\RuntimeException
@@ -214,6 +218,10 @@ public static function fromConfig(array $config, bool $quiet = false): Client
214218
}
215219

216220
/**
221+
* Get the default handler
222+
*
223+
* @param array $multiParams
224+
* @param array $singleParams
217225
* @throws \RuntimeException
218226
*/
219227
public static function defaultHandler(array $multiParams = [], array $singleParams = []): callable
@@ -235,6 +243,8 @@ public static function defaultHandler(array $multiParams = [], array $singlePara
235243
}
236244

237245
/**
246+
* Get the multi handler for async (CurlMultiHandler)
247+
*
238248
* @throws \RuntimeException
239249
*/
240250
public static function multiHandler(array $params = []): CurlMultiHandler
@@ -247,6 +257,8 @@ public static function multiHandler(array $params = []): CurlMultiHandler
247257
}
248258

249259
/**
260+
* Get the handler instance (CurlHandler)
261+
*
250262
* @throws \RuntimeException
251263
*/
252264
public static function singleHandler(): CurlHandler
@@ -258,6 +270,11 @@ public static function singleHandler(): CurlHandler
258270
}
259271
}
260272

273+
/**
274+
* Set connection Factory
275+
*
276+
* @param ConnectionFactoryInterface $connectionFactory
277+
*/
261278
public function setConnectionFactory(ConnectionFactoryInterface $connectionFactory): ClientBuilder
262279
{
263280
$this->connectionFactory = $connectionFactory;
@@ -266,7 +283,10 @@ public function setConnectionFactory(ConnectionFactoryInterface $connectionFacto
266283
}
267284

268285
/**
286+
* Set the connection pool (default is StaticNoPingConnectionPool)
287+
*
269288
* @param AbstractConnectionPool|string $connectionPool
289+
* @param array $args
270290
* @throws \InvalidArgumentException
271291
*/
272292
public function setConnectionPool($connectionPool, array $args = []): ClientBuilder
@@ -283,20 +303,35 @@ public function setConnectionPool($connectionPool, array $args = []): ClientBuil
283303
return $this;
284304
}
285305

306+
/**
307+
* Set the endpoint
308+
*
309+
* @param callable $endpoint
310+
*/
286311
public function setEndpoint(callable $endpoint): ClientBuilder
287312
{
288313
$this->endpoint = $endpoint;
289314

290315
return $this;
291316
}
292317

318+
/**
319+
* Register namespace
320+
*
321+
* @param NamespaceBuilderInterface $namespaceBuilder
322+
*/
293323
public function registerNamespace(NamespaceBuilderInterface $namespaceBuilder): ClientBuilder
294324
{
295325
$this->registeredNamespacesBuilders[] = $namespaceBuilder;
296326

297327
return $this;
298328
}
299329

330+
/**
331+
* Set the transport
332+
*
333+
* @param Transport $transport
334+
*/
300335
public function setTransport(Transport $transport): ClientBuilder
301336
{
302337
$this->transport = $transport;
@@ -305,8 +340,9 @@ public function setTransport(Transport $transport): ClientBuilder
305340
}
306341

307342
/**
343+
* Set the HTTP handler (cURL is default)
344+
*
308345
* @param mixed $handler
309-
* @return $this
310346
*/
311347
public function setHandler($handler): ClientBuilder
312348
{
@@ -315,13 +351,23 @@ public function setHandler($handler): ClientBuilder
315351
return $this;
316352
}
317353

354+
/**
355+
* Set the PSR-3 Logger
356+
*
357+
* @param LoggerInterface $logger
358+
*/
318359
public function setLogger(LoggerInterface $logger): ClientBuilder
319360
{
320361
$this->logger = $logger;
321362

322363
return $this;
323364
}
324365

366+
/**
367+
* Set the PSR-3 tracer
368+
*
369+
* @param LoggerInterface $tracer
370+
*/
325371
public function setTracer(LoggerInterface $tracer): ClientBuilder
326372
{
327373
$this->tracer = $tracer;
@@ -330,6 +376,8 @@ public function setTracer(LoggerInterface $tracer): ClientBuilder
330376
}
331377

332378
/**
379+
* Set the serializer
380+
*
333381
* @param \Elasticsearch\Serializers\SerializerInterface|string $serializer
334382
*/
335383
public function setSerializer($serializer): ClientBuilder
@@ -339,6 +387,11 @@ public function setSerializer($serializer): ClientBuilder
339387
return $this;
340388
}
341389

390+
/**
391+
* Set the hosts (nodes)
392+
*
393+
* @param array $hosts
394+
*/
342395
public function setHosts(array $hosts): ClientBuilder
343396
{
344397
$this->hosts = $hosts;
@@ -365,8 +418,9 @@ public function setApiKey(string $id, string $apiKey): ClientBuilder
365418
}
366419

367420
/**
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
369422
*
423+
* @see https://en.wikipedia.org/wiki/Basic_access_authentication
370424
* @param string $username
371425
* @param string $password
372426
*
@@ -416,13 +470,26 @@ public function setElasticCloudId(string $cloudId): ClientBuilder
416470
return $this;
417471
}
418472

473+
/**
474+
* Set connection parameters
475+
*
476+
* @param array $params
477+
*/
419478
public function setConnectionParams(array $params): ClientBuilder
420479
{
421480
$this->connectionParams = $params;
422481

423482
return $this;
424483
}
425484

485+
/**
486+
* Set number or retries (default is equal to number of nodes)
487+
*
488+
* @param int $retries
489+
* @api $params = [
490+
* 'a' => 'b'
491+
* ]
492+
*/
426493
public function setRetries(int $retries): ClientBuilder
427494
{
428495
$this->retries = $retries;
@@ -431,6 +498,8 @@ public function setRetries(int $retries): ClientBuilder
431498
}
432499

433500
/**
501+
* Set the selector algorithm
502+
*
434503
* @param \Elasticsearch\ConnectionPool\Selectors\SelectorInterface|string $selector
435504
*/
436505
public function setSelector($selector): ClientBuilder
@@ -440,6 +509,12 @@ public function setSelector($selector): ClientBuilder
440509
return $this;
441510
}
442511

512+
/**
513+
* Set sniff on start
514+
*
515+
* @param bool $sniffOnStart enable or disable sniff on start
516+
*/
517+
443518
public function setSniffOnStart(bool $sniffOnStart): ClientBuilder
444519
{
445520
$this->sniffOnStart = $sniffOnStart;
@@ -448,7 +523,10 @@ public function setSniffOnStart(bool $sniffOnStart): ClientBuilder
448523
}
449524

450525
/**
526+
* Set SSL certificate
527+
*
451528
* @param string $cert The name of a file containing a PEM formatted certificate.
529+
* @param string $password if the certificate requires a password
452530
*/
453531
public function setSSLCert(string $cert, string $password = null): ClientBuilder
454532
{
@@ -458,7 +536,10 @@ public function setSSLCert(string $cert, string $password = null): ClientBuilder
458536
}
459537

460538
/**
461-
* @param string $key The name of a file containing a private SSL key.
539+
* Set SSL key
540+
*
541+
* @param string $key The name of a file containing a private SSL key
542+
* @param string $password if the private key requires a password
462543
*/
463544
public function setSSLKey(string $key, string $password = null): ClientBuilder
464545
{
@@ -468,6 +549,8 @@ public function setSSLKey(string $key, string $password = null): ClientBuilder
468549
}
469550

470551
/**
552+
* Set SSL verification
553+
*
471554
* @param bool|string $value
472555
*/
473556
public function setSSLVerification($value = true): ClientBuilder
@@ -499,6 +582,9 @@ public function includePortInHostHeader(bool $enable): ClientBuilder
499582
return $this;
500583
}
501584

585+
/**
586+
* Build and returns the Client object
587+
*/
502588
public function build(): Client
503589
{
504590
$this->buildLoggers();

0 commit comments

Comments
 (0)