From 165c87247df4169ebb6c8fbaf243e9c2ed6ff63c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 14 Dec 2020 13:29:07 +0100 Subject: [PATCH] [Notifier] [Discord] Use private const and mb_strlen() --- .../Component/Notifier/Bridge/Discord/DiscordTransport.php | 4 +++- .../Notifier/Bridge/Discord/Tests/DiscordTransportTest.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php index afa98f77d6b3d..3fb2061290f23 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php @@ -29,6 +29,8 @@ final class DiscordTransport extends AbstractTransport { protected const HOST = 'discord.com'; + private const SUBJECT_LIMIT = 2000; + private $token; private $webhookId; @@ -65,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage $content = $message->getSubject(); - if (\strlen($content) > 2000) { + if (mb_strlen($content, 'UTF-8') > self::SUBJECT_LIMIT) { throw new LogicException('The subject length of a Discord message must not exceed 2000 characters.'); } diff --git a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php index 154a795530fbf..ead3027580662 100644 --- a/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php @@ -56,7 +56,7 @@ public function testSendChatMessageWithMoreThan2000CharsThrowsLogicException() $this->expectException(LogicException::class); $this->expectExceptionMessage('The subject length of a Discord message must not exceed 2000 characters.'); - $transport->send(new ChatMessage(str_repeat('d', 2001))); + $transport->send(new ChatMessage(str_repeat('囍', 2001))); } public function testSendWithErrorResponseThrows() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy