Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
72.22% covered (warning)
72.22%
13 / 18
68.75% covered (warning)
68.75%
11 / 16
CRAP
0.00% covered (danger)
0.00%
0 / 1
NotificationUser
72.22% covered (warning)
72.22%
13 / 18
68.75% covered (warning)
68.75%
11 / 16
21.49
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
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
 getMail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setMail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getToken
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setToken
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNotification
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNotification
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getReadAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setReadAt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * This file is part of the MADIS - RGPD Management application.
5 *
6 * @copyright Copyright (c) 2018-2019 Soluris - Solutions Numériques Territoriales Innovantes
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22declare(strict_types=1);
23
24namespace App\Domain\Notification\Model;
25
26use App\Application\Traits\Model\HistoryTrait;
27use App\Domain\User\Model\User;
28use Doctrine\ORM\Mapping as ORM;
29use Ramsey\Uuid\Uuid;
30use Ramsey\Uuid\UuidInterface;
31
32#[ORM\Entity]
33class NotificationUser
34{
35    use HistoryTrait;
36
37    #[ORM\Id]
38    #[ORM\Column(type: 'uuid', unique: true)]
39    private UuidInterface $id;
40
41    #[ORM\Column(type: 'string', nullable: true)]
42    private ?string $mail;
43
44    #[ORM\ManyToOne(targetEntity: Notification::class, inversedBy: 'notificationUserss')]
45    #[ORM\JoinColumn(name: 'notification_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
46    private Notification $notification;
47
48    #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'notifications')]
49    #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
50    private ?User $user;
51
52    #[ORM\Column(type: 'string', nullable: false)]
53    private string $token;
54
55    #[ORM\Column(type: 'boolean')]
56    private ?bool $active;
57
58    #[ORM\Column(name: 'read_at', type: 'datetime', nullable: true)]
59    private ?\DateTime $readAt = null;
60
61    /**
62     * Has the email been sent for this notification and this user.
63     */
64    #[ORM\Column(type: 'boolean')]
65    private ?bool $sent;
66
67    /**
68     * Category constructor.
69     *
70     * @throws \Exception
71     */
72    public function __construct()
73    {
74        $this->id   = Uuid::uuid4();
75        $this->user = null;
76        $this->mail = null;
77    }
78
79    public function getId(): UuidInterface
80    {
81        return $this->id;
82    }
83
84    public function getMail(): ?string
85    {
86        return $this->mail;
87    }
88
89    public function setMail(?string $mail): void
90    {
91        $this->mail = $mail;
92    }
93
94    public function getToken(): string
95    {
96        return $this->token;
97    }
98
99    public function setToken(string $token): void
100    {
101        $this->token = $token;
102    }
103
104    public function getActive(): ?bool
105    {
106        return $this->active;
107    }
108
109    public function setActive(?bool $active): void
110    {
111        $this->active = $active;
112    }
113
114    public function getNotification(): Notification
115    {
116        return $this->notification;
117    }
118
119    public function setNotification(Notification $notification): void
120    {
121        $this->notification = $notification;
122    }
123
124    public function getUser(): ?User
125    {
126        return $this->user;
127    }
128
129    public function setUser(User $user): void
130    {
131        $this->user = $user;
132    }
133
134    public function getSent(): ?bool
135    {
136        return $this->sent;
137    }
138
139    public function setSent(?bool $sent): void
140    {
141        $this->sent = $sent;
142    }
143
144    public function getReadAt(): ?\DateTime
145    {
146        return $this->readAt;
147    }
148
149    public function setReadAt(?\DateTime $readAt): void
150    {
151        $this->readAt = $readAt;
152    }
153}