Notification::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2020-2025 Iain Cambridge
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
10
 * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
namespace Parthenon\Athena\Entity;
23
24
use Doctrine\ORM\Mapping as ORM;
25
use Ramsey\Uuid\Doctrine\UuidGenerator;
26
27
/**
28
 * @ORM\Entity()
29
 *
30
 * @ORM\Table(name="parthenon_backoffice_notifications")
31
 */
32
class Notification
33
{
34
    /**
35
     * @ORM\Id
36
     *
37
     * @ORM\Column(type="uuid", unique=true)
38
     *
39
     * @ORM\GeneratedValue(strategy="CUSTOM")
40
     *
41
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
42
     */
43
    protected $id;
44
45
    /**
46
     * @ORM\Column(type="string", length=255)
47
     */
48
    protected string $messageTemplate;
49
50
    /**
51
     * @ORM\Embedded(class="Parthenon\Athena\Entity\Link")
52
     */
53
    protected Link $link;
54
55
    /**
56
     * @ORM\Column(type="boolean", nullable=false)
57
     */
58
    protected bool $isRead = false;
59
60
    /**
61
     * @ORM\Column(type="datetime")
62
     */
63
    protected \DateTime $createdAt;
64
65
    /**
66
     * @ORM\Column(type="datetime", nullable=true)
67
     */
68
    protected ?\DateTime $readAt;
69
70
    public function getId()
71
    {
72
        return $this->id;
73
    }
74
75
    public function setId($id): void
76
    {
77
        $this->id = $id;
78
    }
79
80
    public function getMessageTemplate(): string
81
    {
82
        return $this->messageTemplate;
83
    }
84
85
    public function setMessageTemplate(string $messageTemplate): void
86
    {
87
        $this->messageTemplate = $messageTemplate;
88
    }
89
90
    public function getLink(): Link
91
    {
92
        return $this->link;
93
    }
94
95
    public function setLink(Link $link): void
96
    {
97
        $this->link = $link;
98
    }
99
100
    public function isRead(): bool
101
    {
102
        return $this->isRead;
103
    }
104
105
    public function setRead(bool $read): void
106
    {
107
        $this->isRead = $read;
108
    }
109
110
    public function getCreatedAt(): \DateTime
111
    {
112
        return $this->createdAt;
113
    }
114
115
    public function setCreatedAt(\DateTime $createdAt): void
116
    {
117
        $this->createdAt = $createdAt;
118
    }
119
120
    public function getReadAt(): ?\DateTime
121
    {
122
        return $this->readAt;
123
    }
124
125
    public function setReadAt(?\DateTime $readAt): void
126
    {
127
        $this->readAt = $readAt;
128
    }
129
130
    public function markAsRead(): void
131
    {
132
        $this->isRead = true;
133
        $this->readAt = new \DateTime('now');
134
    }
135
}
136