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;
    }