Test Failed
Push — master ( ab043e...0f6c77 )
by Nico
50:13 queued 22:41
created

PrivateMessage::getSender()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\ORM\Mapping\Column;
8
use Doctrine\ORM\Mapping\Entity;
9
use Doctrine\ORM\Mapping\GeneratedValue;
10
use Doctrine\ORM\Mapping\Id;
11
use Doctrine\ORM\Mapping\Index;
12
use Doctrine\ORM\Mapping\JoinColumn;
13
use Doctrine\ORM\Mapping\ManyToOne;
14
use Doctrine\ORM\Mapping\OneToOne;
15
use Doctrine\ORM\Mapping\Table;
16
17
#[Table(name: 'stu_pms')]
18
#[Index(name: 'recipient_folder_idx', columns: ['recip_user', 'cat_id'])]
19
#[Index(name: 'correspondence', columns: ['recip_user', 'send_user'])]
20
#[Entity(repositoryClass: 'Stu\Orm\Repository\PrivateMessageRepository')]
21
class PrivateMessage implements PrivateMessageInterface
22
{
23
    #[Id]
24
    #[Column(type: 'integer')]
25
    #[GeneratedValue(strategy: 'IDENTITY')]
26
    private int $id;
27
28
    #[Column(type: 'integer')]
29
    private int $send_user = 0;
30
31
    #[Column(type: 'integer')]
32
    private int $recip_user = 0;
33
34
    #[Column(type: 'text')]
35
    private string $text = '';
36
37
    #[Column(type: 'integer')]
38
    private int $date = 0;
39
40
    #[Column(type: 'boolean')]
41
    private bool $new = false;
42
43
    #[Column(type: 'boolean')]
44
    private bool $replied = false;
45
46
    #[Column(type: 'integer')]
47
    private int $cat_id = 0;
48
49
    #[Column(type: 'integer', nullable: true)]
50
    private ?int $inbox_pm_id = null;
0 ignored issues
show
introduced by
The private property $inbox_pm_id is not used, and could be removed.
Loading history...
51
52
    #[Column(type: 'string', nullable: true)]
53
    private ?string $href = null;
54
55
    #[Column(type: 'integer', nullable: true)]
56
    private ?int $deleted = null;
57
58
    #[ManyToOne(targetEntity: 'PrivateMessageFolder')]
59
    #[JoinColumn(name: 'cat_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
60
    private PrivateMessageFolderInterface $category;
61
62
    #[ManyToOne(targetEntity: 'User')]
63
    #[JoinColumn(name: 'send_user', referencedColumnName: 'id', onDelete: 'CASCADE')]
64
    private UserInterface $sendingUser;
65
66
    #[ManyToOne(targetEntity: 'User')]
67
    #[JoinColumn(name: 'recip_user', referencedColumnName: 'id', onDelete: 'CASCADE')]
68
    private UserInterface $receivingUser;
69
70
    #[OneToOne(targetEntity: 'PrivateMessage', inversedBy: 'outboxPm')]
71
    #[JoinColumn(name: 'inbox_pm_id', referencedColumnName: 'id')]
72
    private ?PrivateMessageInterface $inboxPm;
73
74
    #[OneToOne(targetEntity: 'PrivateMessage', mappedBy: 'inboxPm')]
75
    private ?PrivateMessageInterface $outboxPm;
76
77
    public function getId(): int
78
    {
79
        return $this->id;
80
    }
81
82
    public function getSenderId(): int
83
    {
84
        return $this->send_user;
85
    }
86
87
    public function getRecipientId(): int
88
    {
89
        return $this->recip_user;
90
    }
91
92
    public function getText(): string
93
    {
94
        return $this->text;
95
    }
96
97
    public function setText(string $text): PrivateMessageInterface
98
    {
99
        $this->text = $text;
100
        return $this;
101
    }
102
103
    public function getDate(): int
104
    {
105
        return $this->date;
106
    }
107
108
    public function setDate(int $date): PrivateMessageInterface
109
    {
110
        $this->date = $date;
111
        return $this;
112
    }
113
114
    public function getNew(): bool
115
    {
116
        return $this->new;
117
    }
118
119
    public function setNew(bool $new): PrivateMessageInterface
120
    {
121
        $this->new = $new;
122
        return $this;
123
    }
124
125
    public function getReplied(): bool
126
    {
127
        return $this->replied;
128
    }
129
130
    public function setReplied(bool $replied): PrivateMessageInterface
131
    {
132
        $this->replied = $replied;
133
        return $this;
134
    }
135
136
    public function getCategoryId(): int
137
    {
138
        return $this->cat_id;
139
    }
140
141
    public function setCategoryId(int $categoryId): PrivateMessageInterface
142
    {
143
        $this->cat_id = $categoryId;
144
        return $this;
145
    }
146
147
    public function getInboxPm(): ?PrivateMessageInterface
148
    {
149
        return $this->inboxPm;
150
    }
151
152
    public function setInboxPm(?PrivateMessageInterface $pm): PrivateMessageInterface
153
    {
154
        $this->inboxPm = $pm;
155
        return $this;
156
    }
157
158
    public function getOutboxPm(): ?PrivateMessageInterface
159
    {
160
        return $this->outboxPm;
161
    }
162
163
    public function getHref(): ?string
164
    {
165
        return $this->href;
166
    }
167
168
    public function setHref(?string $href): PrivateMessageInterface
169
    {
170
        $this->href = $href;
171
        return $this;
172
    }
173
174
    public function getCategory(): PrivateMessageFolderInterface
175
    {
176
        return $this->category;
177
    }
178
179
    public function setCategory(PrivateMessageFolderInterface $folder): PrivateMessageInterface
180
    {
181
        $this->category = $folder;
182
        return $this;
183
    }
184
185
    public function getSender(): UserInterface
186
    {
187
        return $this->sendingUser;
188
    }
189
190
    public function setSender(UserInterface $user): PrivateMessageInterface
191
    {
192
        $this->sendingUser = $user;
193
        return $this;
194
    }
195
196
    public function getRecipient(): UserInterface
197
    {
198
        return $this->receivingUser;
199
    }
200
201
    public function setRecipient(UserInterface $recipient): PrivateMessageInterface
202
    {
203
        $this->receivingUser = $recipient;
204
        return $this;
205
    }
206
207
    public function isDeleted(): bool
208
    {
209
        return $this->deleted !== null;
210
    }
211
212
    public function setDeleted(int $timestamp): PrivateMessageInterface
213
    {
214
        $this->deleted = $timestamp;
215
216
        return $this;
217
    }
218
219
    public function hasTranslation(): bool
220
    {
221
        $text = $this->getText();
222
        return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false;
223
    }
224
}
225