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