Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 928594e

Browse filesBrowse files
committed
feature #39493 [Notifier] Introduce LengthException (OskarStark)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Notifier] Introduce LengthException | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | --- | License | MIT | Doc PR | --- Follows https://github.com/symfony/symfony/pull/39444/files#r542298086 Commits ------- 437cad7 [Notifier] Introduce LengthException
2 parents 7617506 + 437cad7 commit 928594e
Copy full SHA for 928594e

File tree

5 files changed

+31
-10
lines changed
Filter options

5 files changed

+31
-10
lines changed

‎src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Discord/DiscordTransport.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Discord;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
14+
use Symfony\Component\Notifier\Exception\LengthException;
1515
use Symfony\Component\Notifier\Exception\TransportException;
1616
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
1717
use Symfony\Component\Notifier\Message\ChatMessage;
@@ -67,7 +67,7 @@ protected function doSend(MessageInterface $message): SentMessage
6767
$content = $message->getSubject();
6868

6969
if (\strlen($content) > 2000) {
70-
throw new LogicException('The subject length of a Discord message must not exceed 2000 characters.');
70+
throw new LengthException('The subject length of a Discord message must not exceed 2000 characters.');
7171
}
7272

7373
$endpoint = sprintf('https://%s/api/webhooks/%s/%s', $this->getEndpoint(), $this->webhookId, $this->token);

‎src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Discord/Tests/DiscordTransportTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpClient\MockHttpClient;
1616
use Symfony\Component\Notifier\Bridge\Discord\DiscordTransport;
17-
use Symfony\Component\Notifier\Exception\LogicException;
17+
use Symfony\Component\Notifier\Exception\LengthException;
1818
use Symfony\Component\Notifier\Exception\TransportException;
1919
use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException;
2020
use Symfony\Component\Notifier\Message\ChatMessage;
@@ -55,7 +55,7 @@ public function testSendChatMessageWithMoreThan2000CharsThrowsLogicException()
5555
{
5656
$transport = new DiscordTransport('testToken', 'testChannel', $this->createMock(HttpClientInterface::class));
5757

58-
$this->expectException(LogicException::class);
58+
$this->expectException(LengthException::class);
5959
$this->expectExceptionMessage('The subject length of a Discord message must not exceed 2000 characters.');
6060

6161
$transport->send(new ChatMessage(str_repeat('d', 2001)));

‎src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Slack/Block/SlackHeaderBlock.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\Slack\Block;
1313

14-
use Symfony\Component\Notifier\Exception\LogicException;
14+
use Symfony\Component\Notifier\Exception\LengthException;
1515

1616
/**
1717
* @author Tomas Norkūnas <norkunas.tom@gmail.com>
@@ -26,7 +26,7 @@ final class SlackHeaderBlock extends AbstractSlackBlock
2626
public function __construct(string $text)
2727
{
2828
if (\strlen($text) > self::TEXT_LIMIT) {
29-
throw new LogicException(sprintf('Maximum length for the text is %d characters.', self::TEXT_LIMIT));
29+
throw new LengthException(sprintf('Maximum length for the text is %d characters.', self::TEXT_LIMIT));
3030
}
3131

3232
$this->options = [
@@ -41,7 +41,7 @@ public function __construct(string $text)
4141
public function id(string $id): self
4242
{
4343
if (\strlen($id) > self::ID_LIMIT) {
44-
throw new LogicException(sprintf('Maximum length for the block id is %d characters.', self::ID_LIMIT));
44+
throw new LengthException(sprintf('Maximum length for the block id is %d characters.', self::ID_LIMIT));
4545
}
4646

4747
$this->options['block_id'] = $id;

‎src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Slack/Tests/Block/SlackHeaderBlockTest.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackHeaderBlock;
16-
use Symfony\Component\Notifier\Exception\LogicException;
16+
use Symfony\Component\Notifier\Exception\LengthException;
1717

1818
final class SlackHeaderBlockTest extends TestCase
1919
{
@@ -34,15 +34,15 @@ public function testCanBeInstantiated()
3434

3535
public function testThrowsWhenTextExceedsCharacterLimit()
3636
{
37-
$this->expectException(LogicException::class);
37+
$this->expectException(LengthException::class);
3838
$this->expectExceptionMessage('Maximum length for the text is 150 characters.');
3939

4040
new SlackHeaderBlock(str_repeat('h', 151));
4141
}
4242

4343
public function testThrowsWhenBlockIdExceedsCharacterLimit()
4444
{
45-
$this->expectException(LogicException::class);
45+
$this->expectException(LengthException::class);
4646
$this->expectExceptionMessage('Maximum length for the block id is 255 characters.');
4747

4848
$header = new SlackHeaderBlock('header');
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Exception;
13+
14+
/**
15+
* @author Oskar Stark <oskarstark@googlemail.com>
16+
*
17+
* @experimental in 5.3
18+
*/
19+
class LengthException extends LogicException
20+
{
21+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.