Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
6 / 8
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
NotificationType
75.00% covered (warning)
75.00%
6 / 8
50.00% covered (danger)
50.00%
2 / 4
4.25
0.00% covered (danger)
0.00%
0 / 1
 adminTypes
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 allKnownTypes
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isValid
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 isAdminType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Domain\Notification\Data;
6
7/**
8 * Catalog of valid notification type identifiers.
9 *
10 * Mirrors the CHECK constraint on notification_preferences.notification_type.
11 * When new types are added (investor.* or other admin.*), update both this
12 * class and the CHECK constraint via a migration.
13 */
14final class NotificationType
15{
16    public const string ADMIN_CRON_DAILY_ACCRUAL = 'admin.cron.daily_accrual';
17    public const string ADMIN_CRON_MONTHLY_POST = 'admin.cron.monthly_post';
18    public const string ADMIN_CRON_BALANCE_SNAPSHOT = 'admin.cron.balance_snapshot';
19
20    public const string CHANNEL_EMAIL = 'email';
21
22    /**
23     * @return list<string>
24     */
25    public static function adminTypes(): array
26    {
27        return [
28            self::ADMIN_CRON_DAILY_ACCRUAL,
29            self::ADMIN_CRON_MONTHLY_POST,
30            self::ADMIN_CRON_BALANCE_SNAPSHOT,
31        ];
32    }
33
34    /**
35     * @return list<string>
36     */
37    public static function allKnownTypes(): array
38    {
39        return self::adminTypes();
40    }
41
42    public static function isValid(string $type): bool
43    {
44        return in_array($type, self::allKnownTypes(), true);
45    }
46
47    /**
48     * Returns true if the given type targets users with admin or super_admin
49     * role (vs. a single specific investor user).
50     * @param string $type
51     */
52    public static function isAdminType(string $type): bool
53    {
54        return str_starts_with($type, 'admin.');
55    }
56}