1<?php 2/** 3 * Elasticsearch PHP client 4 * 5 * @link https://github.com/elastic/elasticsearch-php/ 6 * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co) 7 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 8 * @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1 9 * 10 * Licensed to Elasticsearch B.V under one or more agreements. 11 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or 12 * the GNU Lesser General Public License, Version 2.1, at your option. 13 * See the LICENSE file in the project root for more information. 14 */ 15 16 17declare(strict_types = 1); 18 19namespace Elasticsearch\Connections; 20 21use Elasticsearch\Serializers\SerializerInterface; 22use Psr\Log\LoggerInterface; 23 24class ConnectionFactory implements ConnectionFactoryInterface 25{ 26 /** 27 * @var array 28 */ 29 private $connectionParams; 30 31 /** 32 * @var SerializerInterface 33 */ 34 private $serializer; 35 36 /** 37 * @var LoggerInterface 38 */ 39 private $logger; 40 41 /** 42 * @var LoggerInterface 43 */ 44 private $tracer; 45 46 /** 47 * @var callable 48 */ 49 private $handler; 50 51 public function __construct(callable $handler, array $connectionParams, SerializerInterface $serializer, LoggerInterface $logger, LoggerInterface $tracer) 52 { 53 $this->handler = $handler; 54 $this->connectionParams = $connectionParams; 55 $this->logger = $logger; 56 $this->tracer = $tracer; 57 $this->serializer = $serializer; 58 } 59 60 public function create(array $hostDetails): ConnectionInterface 61 { 62 return new Connection( 63 $this->handler, 64 $hostDetails, 65 $this->connectionParams, 66 $this->serializer, 67 $this->logger, 68 $this->tracer 69 ); 70 } 71} 72