1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Connections; 6 7use Elasticsearch\Serializers\SerializerInterface; 8use Psr\Log\LoggerInterface; 9 10/** 11 * Class AbstractConnection 12 * 13 * @category Elasticsearch 14 * @package Elasticsearch\Connections 15 * @author Zachary Tong <zach@elastic.co> 16 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 17 * @link http://elastic.co 18 */ 19class ConnectionFactory implements ConnectionFactoryInterface 20{ 21 /** 22 * @var array 23 */ 24 private $connectionParams; 25 26 /** 27 * @var SerializerInterface 28 */ 29 private $serializer; 30 31 /** 32 * @var LoggerInterface 33 */ 34 private $logger; 35 36 /** 37 * @var LoggerInterface 38 */ 39 private $tracer; 40 41 /** 42 * @var callable 43 */ 44 private $handler; 45 46 public function __construct(callable $handler, array $connectionParams, SerializerInterface $serializer, LoggerInterface $logger, LoggerInterface $tracer) 47 { 48 $this->handler = $handler; 49 $this->connectionParams = $connectionParams; 50 $this->logger = $logger; 51 $this->tracer = $tracer; 52 $this->serializer = $serializer; 53 } 54 55 public function create(array $hostDetails): ConnectionInterface 56 { 57 return new Connection( 58 $this->handler, 59 $hostDetails, 60 $this->connectionParams, 61 $this->serializer, 62 $this->logger, 63 $this->tracer 64 ); 65 } 66} 67