lib/Elastica/Transport/AbstractTransport.php
public static function create($transport, Connection $connection, array $params = []): AbstractTransport
    {
        if (\is_array($transport) && isset($transport['type'])) {
            $transportParams = $transport;
            unset($transportParams['type']);

            $params = \array_replace($params, $transportParams);
            $transport = $transport['type'];
        }

        if (\is_string($transport)) {
            $specialTransports = [
                'httpadapter' => 'HttpAdapter',
                'nulltransport' => 'NullTransport',
            ];

            if (isset($specialTransports[\strtolower($transport)])) {
                $transport = $specialTransports[\strtolower($transport)];
            } else {
                $transport = \ucfirst($transport);
            }
            $classNames = ["Elastica\\Transport\\$transport", $transport];
            foreach ($classNames as $className) {
                if (\class_exists($className)) {
                    $transport = new $className();
                    break;
                }
            }
        }

        if ($transport instanceof self) {
            $transport->setConnection($connection);

            foreach ($params as $key => $value) {
                $transport->setParam($key, $value);
            }
        } else {
            throw new InvalidException('Invalid transport');
        }

        return $transport;
    }
public static function create($transport, Connection $connection, array $params = []): AbstractTransport
    {
        if (\is_array($transport) && isset($transport['type'])) {
            $transportParams = $transport;
            unset($transportParams['type']);

            $params = \array_replace($params, $transportParams);
            $transport = $transport['type'];
        }

        if (\is_string($transport)) {
            $specialTransports = [
                'httpadapter' => 'HttpAdapter',
                'nulltransport' => 'NullTransport',
            ];

            if (isset($specialTransports[\strtolower($transport)])) {
                $transport = $specialTransports[\strtolower($transport)];
            } else {
                $transport = \ucfirst($transport);
            }
            $classNames = ["Elastica\\Transport\\$transport", $transport];
            foreach ($classNames as $className) {
                if (\class_exists($className)) {
                    $transport = new $className();
                    break;
                }
            }
        }

        if ($transport instanceof self) {
            $transport->setConnection($connection);

            foreach ($params as $key => $value) {
                $transport->setParam($key, $value);
            }
        } else {
            throw new InvalidException('Invalid transport');
        }

        return $transport;
    }
public static function create ( $ transport , Connection $ connection , array $ params = [ ] ) : AbstractTransport { if ( \ is_array ( $ transport ) && isset ( $ transport [ 'type' ] ) ) { $ transportParams = $ transport ; unset ( $ transportParams [ 'type' ] ) ; $ params = \ array_replace ( $ params , $ transportParams ) ; $ transport = $ transport [ 'type' ] ; } if ( \ is_string ( $ transport ) ) { $ specialTransports = [ 'httpadapter' => 'HttpAdapter' , 'nulltransport' => 'NullTransport' , ] ; if ( isset ( $ specialTransports [ \ strtolower ( $ transport ) ] ) ) { $ transport = $ specialTransports [ \ strtolower ( $ transport ) ] ; } else { $ transport = \ ucfirst ( $ transport ) ; } $ classNames = [ "Elastica\\Transport\\$transport" , $ transport ] ; foreach ( $ classNames as $ className ) { if ( \ class_exists ( $ className ) ) { $ transport = new $ className ( ) ; break ; } } } if ( $ transport instanceof self ) { $ transport -> setConnection ( $ connection ) ; foreach ( $ params as $ key => $ value ) { $ transport -> setParam ( $ key , $ value ) ; } } else { throw new InvalidException ( 'Invalid transport' ) ; } return $ transport ; }
Create a transport.

The $transport parameter can be one of the following values:

* string: The short name of a transport. For instance "Http"
* object: An already instantiated instance of a transport
* array: An array with a "type" key which must be set to one of the two options. All other
keys in the array will be set as parameters in the transport instance

@param mixed      $transport  A transport definition
@param Connection $connection A connection instance
@param array      $params     Parameters for the transport class

@throws InvalidException

@return AbstractTransport
Create a transport .