private function setupConnection($parameters) { if ($parameters === null) { return $this->setConnection($this->createConnection(null)); } if (!(is_array($parameters) || is_string($parameters) || $parameters instanceof IConnection || $parameters instanceof ConnectionParameters)) { throw new \InvalidArgumentException('Array, String, Predis\\ConnectionParameters or Predis\\IConnection expected'); } if (is_array($parameters) && isset($parameters[0])) { $cluster = new ConnectionCluster($this->_options->key_distribution); foreach ($parameters as $shardParams) { $cluster->add($this->createConnection($shardParams)); } $this->setConnection($cluster); } else { $this->setConnection($this->createConnection($parameters)); } }
private function setupConnection($parameters) { if ($parameters !== null && !(is_array($parameters) || is_string($parameters))) { throw new ClientException('Invalid parameters type (array or string expected)'); } if (is_array($parameters) && isset($parameters[0])) { $cluster = new ConnectionCluster($this->_options->key_distribution); foreach ($parameters as $shardParams) { $cluster->add($this->createConnection($shardParams)); } $this->setConnection($cluster); } else { $this->setConnection($this->createConnection($parameters)); } }