From d629976322a54cf6ee8433303bb0f17a46b1b7fc Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Sat, 5 Mar 2022 14:25:01 +0000 Subject: [PATCH] [UTIL][Notification] Remove deprecated code --- src/Util/Notification/AbstractTransport.php | 107 ------------------- src/Util/Notification/Notification.php | 64 ----------- tests/Util/Notification/NotificationTest.php | 37 ------- 3 files changed, 208 deletions(-) delete mode 100644 src/Util/Notification/AbstractTransport.php delete mode 100644 src/Util/Notification/Notification.php delete mode 100644 tests/Util/Notification/NotificationTest.php diff --git a/src/Util/Notification/AbstractTransport.php b/src/Util/Notification/AbstractTransport.php deleted file mode 100644 index beb351a373..0000000000 --- a/src/Util/Notification/AbstractTransport.php +++ /dev/null @@ -1,107 +0,0 @@ -. -// }}} - -/** - * Base class for Transports - * - * @package GNUsocial - * @category Util - * - * @author Hugo Sales - * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ - -namespace App\Util\Notification; - -use function App\Core\I18n\_m; -use InvalidArgumentException; - -/** - * @codeCoverageIgnore - */ -abstract class AbstractTransport -{ - /** - * Get the display name of this transport - */ - abstract public function getName(): string; - - /** - * Get the identifier used in code for this transport - */ - abstract public function getIdentifier(): string; - - /** - * Send a given Notification through this transport - */ - abstract public function send(Notification $n): bool; - - /** - * Get the display help message for one of the Notification-constants type - */ - public function getHelpMessage(int $t): string - { - switch ($t) { - case Notification::NOTICE_BY_SUBSCRIBED: - return _m('Send me alerts of mentions by those I subscribe through {name}', ['{name}' => $this->getName()]); - case Notification::MENTION: - return _m('Send me alerts of mentions through {name}', ['{name}' => $this->getName()]); - case Notification::REPLY: - return _m('Send me alerts of replies to my notice through {name}', ['{name}' => $this->getName()]); - case Notification::SUBSCRIPTION: - return _m('Send me alerts of new subscriptions through {name}', ['{name}' => $this->getName()]); - case Notification::FAVORITE: - return _m('Send me alerts of new favorites on my notices through {name}', ['{name}' => $this->getName()]); - case Notification::NUDGE: - return _m('Send me alerts when someone calls for my attention through {name}', ['{name}' => $this->getName()]); - case Notification::DM: - return _m('Send me alerts of new direct messages through {name}', ['{name}' => $this->getName()]); - default: - throw new InvalidArgumentException('Given an invalid Notification constant value'); - } - } - - /** - * Get the display label message for one of the Notification-constants type - */ - public function getLabelMessage(int $t): string - { - switch ($t) { - case Notification::NOTICE_BY_SUBSCRIBED: - return _m('Notify me of new notices'); - case Notification::MENTION: - return _m('Notify me of mentions'); - case Notification::REPLY: - return _m('Notify me of replies'); - case Notification::SUBSCRIPTION: - return _m('Notify me of new subscriptions'); - case Notification::FAVORITE: - return _m('Notify me of new favorites'); - case Notification::NUDGE: - return _m('Notify me when nudged'); - case Notification::DM: - return _m('Notify of new DMs'); - default: - throw new InvalidArgumentException('Given an invalid Notification constant value'); - } - } -} diff --git a/src/Util/Notification/Notification.php b/src/Util/Notification/Notification.php deleted file mode 100644 index 97fe0fc97c..0000000000 --- a/src/Util/Notification/Notification.php +++ /dev/null @@ -1,64 +0,0 @@ -. -// }}} - -/** - * Common utility functions - * - * @package GNUsocial - * @category Util - * - * @author Hugo Sales - * @copyright 2020-2021 Free Software Foundation, Inc http://www.fsf.org - * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later - */ - -namespace App\Util\Notification; - -use App\Entity\Actor; - -class Notification -{ - public const NOTICE_BY_SUBSCRIBED = 1; - public const MENTION = 2; - public const REPLY = 3; - public const SUBSCRIPTION = 4; - public const FAVORITE = 5; - public const NUDGE = 6; - public const DM = 7; - - /** - * @param int $type One of the above constants - * @param Actor $actor Who caused this notification - */ - public function __construct(private int $type, private Actor $actor) - { - } - - public function getType(): int - { - return $this->type; - } - - public function getActor(): Actor - { - return $this->actor; - } -} diff --git a/tests/Util/Notification/NotificationTest.php b/tests/Util/Notification/NotificationTest.php deleted file mode 100644 index b474ddfb74..0000000000 --- a/tests/Util/Notification/NotificationTest.php +++ /dev/null @@ -1,37 +0,0 @@ -. -// }}} - -namespace App\Tests\Util\Notification; - -use App\Entity\Actor; -use App\Util\Notification\Notification; -use Jchook\AssertThrows\AssertThrows; -use PHPUnit\Framework\TestCase; - -class NotificationTest extends TestCase -{ - use AssertThrows; - - public function testNotificationBitmap() - { - static::assertTrue((new Notification(Notification::DM, new Actor())) instanceof Notification); - } -}