This commit is contained in:
@ -14,6 +14,8 @@ use InvalidArgumentException;
|
||||
*/
|
||||
class Ntfy implements NotificationInterface
|
||||
{
|
||||
const TOPIC_MAX_LENGTH = 256;
|
||||
const MESSAGE_MAX_LENGTH = 4096;
|
||||
private string $topic = 'default';
|
||||
|
||||
/**
|
||||
@ -42,11 +44,11 @@ class Ntfy implements NotificationInterface
|
||||
/**
|
||||
* Set the topic of the notification message.
|
||||
*
|
||||
* @param string $topic Topic length between 1 and 256 characters.
|
||||
* @param string $topic Topic length between 1 and TOPIC_MAX_LENGTH characters.
|
||||
*/
|
||||
public function setTopic(string $topic): void
|
||||
{
|
||||
if (strlen($topic) < 1 || strlen($topic) >= 256) {
|
||||
if (!strlen($topic) || strlen($topic) > self::TOPIC_MAX_LENGTH) {
|
||||
throw new InvalidArgumentException("Invalid topic length");
|
||||
}
|
||||
|
||||
@ -66,11 +68,11 @@ class Ntfy implements NotificationInterface
|
||||
*/
|
||||
public function send(string $title, string $message): void
|
||||
{
|
||||
if (strlen($title) < 1 || strlen($title) >= 256) {
|
||||
if (!strlen($title) || strlen($title) > self::TOPIC_MAX_LENGTH) {
|
||||
throw new InvalidArgumentException("Invalid title length");
|
||||
}
|
||||
|
||||
if (strlen($message) < 1 || strlen($message) >= 4096) {
|
||||
if (!strlen($message) || strlen($message) > self::MESSAGE_MAX_LENGTH) {
|
||||
throw new InvalidArgumentException("Invalid message length");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user