@@ -388,33 +388,33 @@ |
||
388 | 388 | */ |
389 | 389 | private function connectToElastic(array $hosts) { |
390 | 390 | |
391 | - try { |
|
392 | - $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
393 | - $cb = ClientBuilder::create() |
|
394 | - ->setHosts($hosts) |
|
395 | - ->setRetries(3); |
|
396 | - $this->configureAuthentication($cb, $hosts); |
|
397 | - |
|
398 | - $this->client = $cb->build(); |
|
399 | - } catch (Exception $e) { |
|
400 | - throw $e; |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
406 | - */ |
|
407 | - private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
408 | - foreach ($hosts as $host) { |
|
409 | - $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
410 | - $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
411 | - |
|
412 | - if ($user !== '' || $pass !== '') { |
|
413 | - $cb->setBasicAuthentication($user, $pass); |
|
414 | - return; |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
391 | + try { |
|
392 | + $hosts = array_map([$this, 'cleanHost'], $hosts); |
|
393 | + $cb = ClientBuilder::create() |
|
394 | + ->setHosts($hosts) |
|
395 | + ->setRetries(3); |
|
396 | + $this->configureAuthentication($cb, $hosts); |
|
397 | + |
|
398 | + $this->client = $cb->build(); |
|
399 | + } catch (Exception $e) { |
|
400 | + throw $e; |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * setBasicAuthentication() on ClientBuilder if available, using list of hosts |
|
406 | + */ |
|
407 | + private function configureAuthentication(ClientBuilder $cb, array $hosts): void { |
|
408 | + foreach ($hosts as $host) { |
|
409 | + $user = parse_url($host, PHP_URL_USER) ?? ''; |
|
410 | + $pass = parse_url($host, PHP_URL_PASS) ?? ''; |
|
411 | + |
|
412 | + if ($user !== '' || $pass !== '') { |
|
413 | + $cb->setBasicAuthentication($user, $pass); |
|
414 | + return; |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | 418 | |
419 | 419 | |
420 | 420 | /** |