public function getClient($host, $username = null, $password = null) { $address = "tcp://{$host}:5222"; $options = new Options($address); if ($this->logger) { $options->setLogger($this->logger); } if ($username && $password) { $this->log("Logging with {$username} | {$password}"); $options->setUsername($username)->setPassword($password); $options->setImplementation(new AuthenticatedImplementation()); } else { $options->setImplementation(new AnonymousImplementation()); $options->setAuthenticationClasses([]); } $client = new Client($options); $client->connect(); return $client; }