setTopic($config['topic']); } return $instance; } public function __construct(Client $client) { $this->client = $client; } public function setTopic(string $topic): void { if (strlen($topic) < 1 || strlen($topic) >= 256) { throw new InvalidArgumentException("Invalid topic length"); } $this->topic = $topic; } public function getTopic(): string { return $this->topic; } public function send(string $title, string $message): void { if (strlen($title) < 1 || strlen($title) >= 256) { throw new InvalidArgumentException("Invalid title length"); } if (strlen($message) < 1 || strlen($message) >= 4096) { throw new InvalidArgumentException("Invalid message length"); } $msg = new Message(); $msg->topic($this->getTopic()); $msg->title($title); $msg->body($message); $this->client->send($msg); } }