private function getTypeForMessage(Message $message) { $msg = $this->transport->prepareTextForMessage($message->getContent()); switch ($message->getType()) { case Message::TYPE_ASCII: return mb_strlen($msg) <= $this->getSinglePartMaxLength(Sender::TYPE_SMS) ? Sender::TYPE_SMS : Sender::TYPE_CONCAT; case Message::TYPE_UNICODE: return mb_strlen($msg) <= $this->getSinglePartMaxLength(Sender::TYPE_UNICODE) ? Sender::TYPE_UNICODE : Sender::TYPE_UNICODE_CONCAT; } throw new \InvalidArgumentException('Never happens :D'); }
/** * @param Message $message * @param PhoneNumber $recipient * @throws SenderException * @return bool */ public function send(Message $message, PhoneNumber $recipient) { $params = ['api_key' => $this->apiKey, 'api_secret' => $this->apiSecret, 'from' => $this->senderName, 'to' => $recipient->getCountryCode() . $recipient->getNationalNumber(), 'text' => $message->getContent(), 'type' => $message->getType() === Message::TYPE_UNICODE ? "unicode" : "text"]; $url = self::NEXTMO_ENDPOINT . '?' . http_build_query($params); $response = $this->getResponse($url); if (false === isset($response['messages'])) { throw new SenderException('Invalid nexmo response: ' . var_export($response, true)); } foreach ($response['messages'] as $message) { if ($message['status'] !== "0") { throw new SenderException($message['error-text'], $message['status']); } } return true; }
public function getContent() { return $this->prefix . $this->message->getContent(); }
public function getContent() { return $this->unicodeRemover->removeUnicode($this->message->getContent()); }