replaced allowed mentions with enum
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum DiscordAllowedMentionType: string
|
||||
{
|
||||
case Everyone = 'everyone';
|
||||
case Roles = 'roles';
|
||||
case Users = 'users';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Everyone => '@everyone and @here',
|
||||
self::Roles => 'Role mentions (@role)',
|
||||
self::Users => 'User mentions (@username)',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{label: string, value: string}>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
return array_map(
|
||||
fn (self $eventType): array => [
|
||||
'label' => $eventType->label(),
|
||||
'value' => $eventType->value,
|
||||
],
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, self>|null $discordAllowedMentionTypes
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function values(?array $discordAllowedMentionTypes = null): array
|
||||
{
|
||||
return array_map(
|
||||
fn (self $discordAllowedMentionType): string => $discordAllowedMentionType->value,
|
||||
$discordAllowedMentionTypes ?? self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,16 @@ enum NotificationChannel: string
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, self>|null $notificationChannels
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function values(?array $notificationChannels = null): array
|
||||
{
|
||||
return array_map(
|
||||
fn (self $notificationChannel): string => $notificationChannel->value,
|
||||
$notificationChannels ?? self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,16 @@ enum NotificationEventType: string
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, self>|null $notificationEventTypes
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function values(?array $notificationEventTypes = null): array
|
||||
{
|
||||
return array_map(
|
||||
fn (self $notificationEventType): string => $notificationEventType->value,
|
||||
$notificationEventTypes ?? self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user