xmpp_options = new Options(); } public function start(): void { $this->xmpp_options->setHost($this->config->xmpp_server); $this->xmpp_options->setUseTls($this->config->xmpp_tls); $this->xmpp_options->setUsername($this->config->xmpp_username); $this->xmpp_options->setPassword($this->config->xmpp_password); $this->xmpp_client = new XmppClient($this->xmpp_options); } public function connect(): void { $this->xmpp_client->connect(); } public function sendMessage(string $text): void { foreach($this->config->xmpp_recipients as $receipient) { $type = $this->getChatType($receipient['type']); if($type === "groupchat") { $this->xmpp_client->send(""); } $this->xmpp_client->message->send($text,$receipient['jid'],$type); } } private function getChatType(int $type): string { if($type === 1) { $return_type = "chat"; } elseif($type === 2) { $return_type = "groupchat"; } else { $return_type = "chat"; } return $return_type; } public function disconnect(): void { $this->xmpp_client->disconnect(); } } ?>