executeCommand($name, $params); } return parent::__call($name, $params); } public function getConnection(): ClientInterface { if ($this->_client === null) { $this->_client = new Client($this->prepareParams(), $this->options); } return $this->_client; } public function executeCommand(string $name, array $params = []) { return $this->getConnection()->$name(...$params); } private function prepareParams() { if ($this->parameters !== null) { return $this->parameters; } if ($this->unixSocket) { $parameters = [ 'scheme' => 'unix', 'path' => $this->unixSocket, ]; } else { $parameters = [ 'scheme' => 'tcp', 'host' => $this->hostname, 'port' => $this->port, ]; } return array_merge($parameters, [ 'database' => $this->database, ]); } }