for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace AmaTeam\ElasticSearch\API;
use Elasticsearch\Client;
use Elasticsearch\ClientBuilder;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
class DefaultClientFactory implements ClientFactoryInterface
{
/**
* @var string[]
*/
private $hosts;
* @var LoggerInterface
private $logger;
* @param string[] $hosts
public function __construct($hosts = ['localhost:9200'])
$this->hosts = $hosts;
$this->logger = new NullLogger();
}
public function getClient(): Client
return ClientBuilder::create()->setHosts($this->hosts)->build();
* @return DefaultClientFactory
public function setHosts(string ...$hosts): DefaultClientFactory
return $this;
* @param LoggerInterface $logger
public function setLogger(LoggerInterface $logger): DefaultClientFactory
$this->logger = $logger;