protected function createConnection($parameters, OptionsInterface $options)
    {
        if ($parameters instanceof ConnectionInterface) {
            if ($parameters->getEventLoop() !== $this->options->eventloop) {
                throw new ClientException('Client and connection must share the same event loop.');
            }

            return $parameters;
        }

        $eventloop = $this->options->eventloop;
        $parameters = $this->createParameters($parameters);

        if ($options->phpiredis) {
            $connection = new PhpiredisStreamConnection($eventloop, $parameters);
        } else {
            $connection = new StreamConnection($eventloop, $parameters);
        }

        if (isset($options->on_error)) {
            $this->setErrorCallback($connection, $options->on_error);
        }

        return $connection;
    }
protected function createConnection($parameters, OptionsInterface $options)
    {
        if ($parameters instanceof ConnectionInterface) {
            if ($parameters->getEventLoop() !== $this->options->eventloop) {
                throw new ClientException('Client and connection must share the same event loop.');
            }

            return $parameters;
        }

        $eventloop = $this->options->eventloop;
        $parameters = $this->createParameters($parameters);

        if ($options->phpiredis) {
            $connection = new PhpiredisStreamConnection($eventloop, $parameters);
        } else {
            $connection = new StreamConnection($eventloop, $parameters);
        }

        if (isset($options->on_error)) {
            $this->setErrorCallback($connection, $options->on_error);
        }

        return $connection;
    }
protected function createConnection ( $ parameters , OptionsInterface $ options ) { if ( $ parameters instanceof ConnectionInterface ) { if ( $ parameters -> getEventLoop ( ) !== $ this -> options -> eventloop ) { throw new ClientException ( 'Client and connection must share the same event loop.' ) ; } return $ parameters ; } $ eventloop = $ this -> options -> eventloop ; $ parameters = $ this -> createParameters ( $ parameters ) ; if ( $ options -> phpiredis ) { $ connection = new PhpiredisStreamConnection ( $ eventloop , $ parameters ) ; } else { $ connection = new StreamConnection ( $ eventloop , $ parameters ) ; } if ( isset ( $ options -> on_error ) ) { $ this -> setErrorCallback ( $ connection , $ options -> on_error ) ; } return $ connection ; }
Initializes a connection from various types of arguments or returns the
passed object if it implements Predis\Connection\ConnectionInterface.

@param mixed            $parameters Connection parameters or instance.
@param OptionsInterface $options    Client options.

@return ConnectionInterface
Initializes a connection from various types of arguments or returns the passed object if it implements Predis \ Connection \ ConnectionInterface .