code: protected function createConnection($parameters)
      {
          $options = $this->getOptions();
  
          if ($parameters instanceof ConnectionInterface) {
              return $parameters;
          }
  
          if ($parameters instanceof ParametersInterface || is_string($parameters)) {
              return $options->connections->create($parameters);
          }
  
          if (is_array($parameters)) {
              if (!isset($parameters[0])) {
                  return $options->connections->create($parameters);
              }
  
              if ($options->defined('cluster')) {
                  return $this->createAggregateConnection($parameters, 'cluster');
              } elseif ($options->defined('replication')) {
                  return $this->createAggregateConnection($parameters, 'replication');
              } elseif ($options->defined('aggregate')) {
                  return $this->createAggregateConnection($parameters, 'aggregate');
              } else {
                  throw new \InvalidArgumentException(
                      'Array of connection parameters requires `cluster`, `replication` or `aggregate` client option'
                  );
              }
          }
  
          if (is_callable($parameters)) {
              $connection = call_user_func($parameters, $options);
  
              if (!$connection instanceof ConnectionInterface) {
                  throw new \InvalidArgumentException('Callable parameters must return a valid connection');
              }
  
              return $connection;
          }
  
          throw new \InvalidArgumentException('Invalid type for connection parameters');
      }
docs: Creates single or aggregate connections from different types of arguments
  (string, array) or returns the passed argument if it is an instance of a
  class implementing Predis\Connection\ConnectionInterface.
  
  Accepted types for connection parameters are:
  
  - Instance of Predis\Connection\ConnectionInterface.
  - Instance of Predis\Connection\ParametersInterface.
  - Array
  - String
  - Callable
  
  @param mixed $parameters Connection parameters or connection instance.
  
  @throws \InvalidArgumentException
  
  @return ConnectionInterface