Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
22.73% covered (danger)
22.73%
5 / 22
5.56% covered (danger)
5.56%
1 / 18
CRAP
0.00% covered (danger)
0.00%
0 / 1
EmailNotificationPreference
22.73% covered (danger)
22.73%
5 / 22
5.56% covered (danger)
5.56%
1 / 18
167.49
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 getId
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
 getFrequency
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setFrequency
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHour
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setHour
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getWeek
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setWeek
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDay
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDay
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLastSent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLastSent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNotificationMask
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNotificationMask
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEnabled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setEnabled
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Domain\User\Model;
4
5use App\Application\Traits\Model\HistoryTrait;
6use Ramsey\Uuid\Uuid;
7use Ramsey\Uuid\UuidInterface;
8
9class EmailNotificationPreference
10{
11    use HistoryTrait;
12
13    public const NOTIF_TREATMENT               = 1;
14    public const NOTIF_SUBCONTRACTOR           = 2;
15    public const NOTIF_REQUEST                 = 4;
16    public const NOTIF_VIOLATION               = 8;
17    public const NOTIF_PROOF                   = 16;
18    public const NOTIF_PROTECT_ACTION          = 32;
19    public const NOTIF_MATURITY                = 64;
20    public const NOTIF_TREATMENT_CONFORMITY    = 128;
21    public const NOTIF_ORGANIZATION_CONFORMITY = 256;
22    public const NOTIF_AIPD                    = 512;
23    public const NOTIF_DOCUMENT                = 1024;
24
25    public const FREQUENCY_NONE  = 'none';
26    public const FREQUENCY_EACH  = 'each';
27    public const FREQUENCY_HOUR  = 'hour';
28    public const FREQUENCY_DAY   = 'day';
29    public const FREQUENCY_WEEK  = 'week';
30    public const FREQUENCY_MONTH = 'month';
31
32    public const MODULES = [
33        'treatment'               => self::NOTIF_TREATMENT,
34        'contractor'              => self::NOTIF_SUBCONTRACTOR,
35        'request'                 => self::NOTIF_REQUEST,
36        'violation'               => self::NOTIF_VIOLATION,
37        'proof'                   => self::NOTIF_PROOF,
38        'mesurement'              => self::NOTIF_PROTECT_ACTION,
39        'maturity_survey'         => self::NOTIF_MATURITY,
40        'treatment_conformity'    => self::NOTIF_TREATMENT_CONFORMITY,
41        'organization_conformity' => self::NOTIF_ORGANIZATION_CONFORMITY,
42        'aipd'                    => self::NOTIF_AIPD,
43        'documentation'           => self::NOTIF_DOCUMENT,
44    ];
45
46    /**
47     * @var UuidInterface
48     */
49    private $id;
50
51    private User $user;
52
53    private string $frequency;
54
55    private bool $enabled;
56
57    private ?int $hour;
58
59    private ?int $week;
60
61    private ?int $day;
62
63    private int $notificationMask;
64
65    private ?\DateTime $lastSent;
66
67    public function __construct()
68    {
69        $this->id               = Uuid::uuid4();
70        $this->notificationMask = 2047;     // All active by default. https://gitlab.adullact.net/soluris/madis/-/issues/632
71        $this->enabled          = 1;
72        $this->frequency        = 'none';
73        $this->lastSent         = new \DateTime();
74    }
75
76    public function getId(): UuidInterface
77    {
78        return $this->id;
79    }
80
81    public function getUser(): User
82    {
83        return $this->user;
84    }
85
86    public function setUser(User $user): void
87    {
88        $this->user = $user;
89    }
90
91    public function getFrequency(): ?string
92    {
93        return $this->frequency;
94    }
95
96    public function setFrequency(?string $frequency): void
97    {
98        $this->frequency = $frequency;
99    }
100
101    public function getHour(): ?int
102    {
103        return $this->hour;
104    }
105
106    public function setHour(?int $hour): void
107    {
108        $this->hour = $hour;
109    }
110
111    public function getWeek(): ?int
112    {
113        return $this->week;
114    }
115
116    public function setWeek(?int $week): void
117    {
118        $this->week = $week;
119    }
120
121    public function getDay(): ?int
122    {
123        return $this->day;
124    }
125
126    public function setDay(?int $day): void
127    {
128        $this->day = $day;
129    }
130
131    public function getLastSent(): ?\DateTime
132    {
133        return $this->lastSent;
134    }
135
136    public function setLastSent(?\DateTime $lastSent,
137    ): void {
138        $this->lastSent = $lastSent;
139    }
140
141    public function getNotificationMask(): int
142    {
143        return $this->notificationMask;
144    }
145
146    public function setNotificationMask(int $notificationMask): void
147    {
148        $this->notificationMask = $notificationMask;
149    }
150
151    /**
152     * @return bool|int
153     */
154    public function getEnabled()
155    {
156        return $this->enabled;
157    }
158
159    /**
160     * @param bool|int $enabled
161     */
162    public function setEnabled($enabled): void
163    {
164        $this->enabled = $enabled;
165    }
166}