Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 13 |
CRAP | |
0.00% |
0 / 1 |
NotificationSubscription | |
0.00% |
0 / 19 |
|
0.00% |
0 / 13 |
210 | |
0.00% |
0 / 1 |
__toString | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
setId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDeliveryType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setDeliveryType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getNotificationType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setNotificationType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getNotificationTypeArgs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setNotificationTypeArgs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCreatedAt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Entity; |
4 | |
5 | use Doctrine\ORM\Mapping as ORM; |
6 | use Olz\Entity\Users\User; |
7 | use Olz\Repository\NotificationSubscriptionRepository; |
8 | |
9 | #[ORM\Table(name: 'notification_subscriptions')] |
10 | #[ORM\Index(name: 'user_id_index', columns: ['user_id'])] |
11 | #[ORM\Index(name: 'notification_type_index', columns: ['notification_type'])] |
12 | #[ORM\Entity(repositoryClass: NotificationSubscriptionRepository::class)] |
13 | class NotificationSubscription { |
14 | public const DELIVERY_EMAIL = 'email'; |
15 | public const DELIVERY_TELEGRAM = 'telegram'; |
16 | |
17 | public const ALL_DELIVERY_TYPES = [ |
18 | self::DELIVERY_EMAIL, |
19 | self::DELIVERY_TELEGRAM, |
20 | ]; |
21 | |
22 | public const TYPE_DAILY_SUMMARY = 'daily_summary'; |
23 | public const TYPE_DEADLINE_WARNING = 'deadline_warning'; |
24 | public const TYPE_EMAIL_CONFIG_REMINDER = 'email_config_reminder'; |
25 | public const TYPE_IMMEDIATE = 'immediate'; |
26 | public const TYPE_MONTHLY_PREVIEW = 'monthly_preview'; |
27 | public const TYPE_ROLE_REMINDER = 'role_reminder'; |
28 | public const TYPE_TELEGRAM_CONFIG_REMINDER = 'telegram_config_reminder'; |
29 | public const TYPE_WEEKLY_PREVIEW = 'weekly_preview'; |
30 | public const TYPE_WEEKLY_SUMMARY = 'weekly_summary'; |
31 | |
32 | public const ALL_NOTIFICATION_TYPES = [ |
33 | self::TYPE_DAILY_SUMMARY, |
34 | self::TYPE_DEADLINE_WARNING, |
35 | self::TYPE_EMAIL_CONFIG_REMINDER, |
36 | self::TYPE_IMMEDIATE, |
37 | self::TYPE_MONTHLY_PREVIEW, |
38 | self::TYPE_ROLE_REMINDER, |
39 | self::TYPE_TELEGRAM_CONFIG_REMINDER, |
40 | self::TYPE_WEEKLY_PREVIEW, |
41 | self::TYPE_WEEKLY_SUMMARY, |
42 | ]; |
43 | |
44 | #[ORM\Column(type: 'string', nullable: false)] |
45 | private string $delivery_type; |
46 | |
47 | #[ORM\ManyToOne(targetEntity: User::class)] |
48 | #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false)] |
49 | private User $user; |
50 | |
51 | #[ORM\Column(type: 'string', nullable: false)] |
52 | private string $notification_type; |
53 | |
54 | #[ORM\Column(type: 'text', nullable: true)] |
55 | private ?string $notification_type_args; |
56 | |
57 | #[ORM\Column(type: 'datetime', nullable: false)] |
58 | private \DateTime $created_at; |
59 | |
60 | #[ORM\Id] |
61 | #[ORM\Column(type: 'bigint', nullable: false)] |
62 | #[ORM\GeneratedValue] |
63 | private int|string $id; |
64 | |
65 | public function __toString() { |
66 | $label = 'NotificationSubscription('; |
67 | $label .= "delivery_type={$this->getDeliveryType()}, "; |
68 | $label .= "user={$this->getUser()->getId()}, "; |
69 | $label .= "notification_type={$this->getNotificationType()}, "; |
70 | $label .= "notification_type_args={$this->getNotificationTypeArgs()}, "; |
71 | $label .= ')'; |
72 | return $label; |
73 | } |
74 | |
75 | public function getId(): ?int { |
76 | return isset($this->id) ? intval($this->id) : null; |
77 | } |
78 | |
79 | public function setId(int $new_id): void { |
80 | $this->id = $new_id; |
81 | } |
82 | |
83 | public function getDeliveryType(): string { |
84 | return $this->delivery_type; |
85 | } |
86 | |
87 | public function setDeliveryType(string $new_delivery_type): void { |
88 | $this->delivery_type = $new_delivery_type; |
89 | } |
90 | |
91 | public function getUser(): User { |
92 | return $this->user; |
93 | } |
94 | |
95 | public function setUser(User $new_user): void { |
96 | $this->user = $new_user; |
97 | } |
98 | |
99 | public function getNotificationType(): string { |
100 | return $this->notification_type; |
101 | } |
102 | |
103 | public function setNotificationType(string $new_notification_type): void { |
104 | $this->notification_type = $new_notification_type; |
105 | } |
106 | |
107 | public function getNotificationTypeArgs(): ?string { |
108 | return $this->notification_type_args; |
109 | } |
110 | |
111 | public function setNotificationTypeArgs(?string $new_notification_type_args): void { |
112 | $this->notification_type_args = $new_notification_type_args; |
113 | } |
114 | |
115 | public function getCreatedAt(): \DateTime { |
116 | return $this->created_at; |
117 | } |
118 | |
119 | public function setCreatedAt(\DateTime $new_created_at): void { |
120 | $this->created_at = $new_created_at; |
121 | } |
122 | } |