Test Failed
Push — dev ( d9ea74...46b33e )
by Nico
09:52
created

KnPostArchiv::setRpgPlot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Orm\Entity;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\ORM\Mapping\Column;
10
use Doctrine\ORM\Mapping\Entity;
11
use Doctrine\ORM\Mapping\GeneratedValue;
12
use Doctrine\ORM\Mapping\Id;
13
use Doctrine\ORM\Mapping\Index;
14
use Doctrine\ORM\Mapping\JoinColumn;
15
use Doctrine\ORM\Mapping\ManyToOne;
16
use Doctrine\ORM\Mapping\OneToMany;
17
use Doctrine\ORM\Mapping\OrderBy;
18
use Doctrine\ORM\Mapping\Table;
19
use Stu\Module\Communication\View\ShowSingleKn\ShowSingleKn;
20
21
/**
22
 * @Entity(repositoryClass="Stu\Orm\Repository\KnPostArchivRepository")
23
 * @Table(
24
 *     name="stu_kn_archiv",
25
 *     indexes={
26
 *         @Index(name="plot_archiv_idx", columns={"plot_id"}),
27
 *         @Index(name="kn_post_archiv_date_idx", columns={"date"}),
28
 *     }
29
 * )
30
 **/
31
class KnPostArchiv implements KnPostArchivInterface
32
{
33
    /**
34
     * @Id
35
     * @Column(type="integer")
36
     * @GeneratedValue(strategy="IDENTITY")
37
     *
38
     */
39
    private int $id;
40
41
    /**
42
     * @Column(type="string", nullable=true)
43
     *
44
     */
45
    private ?string $version = '';
46
47
    /**
48
     * @Column(type="integer", nullable=true)
49
     *
50
     */
51
    private ?int $former_id;
52
53
    /**
54
     * @Column(type="string", nullable=true)
55
     *
56
     */
57
    private ?string $titel = '';
58
59
    /**
60
     * @Column(type="text", nullable=true)
61
     *
62
     */
63
    private ?string $text = '';
64
65
    /**
66
     * @Column(type="integer", nullable=true)
67
     *
68
     */
69
    private ?int $date = 0;
70
71
    /**
72
     * @Column(type="string", nullable=true)
73
     *
74
     */
75
    private ?string $username = '';
76
77
    /**
78
     * @Column(type="integer", nullable=true)
79
     *
80
     */
81
    private ?int $user_id = 0;
82
83
    /**
84
     * @Column(type="integer", nullable=true)
85
     *
86
     */
87
    private ?int $del_user_id = 0;
88
89
    /**
90
     * @Column(type="integer", nullable=true)
91
     *
92
     */
93
    private ?int $lastedit = 0;
94
95
    /**
96
     * @Column(type="integer", nullable=true)
97
     *
98
     */
99
    private ?int $plot_id = null;
100
101
    /**
102
     * @Column(type="json")
103
     *
104
     * @var array<mixed>
105
     */
106
    private array $ratings = [];
107
108
    /**
109
     * @var ArrayCollection<int, KnCommentArchivInterface>
110
     *
111
     * @OneToMany(targetEntity="KnCommentArchiv", mappedBy="post")
112
     * @OrderBy({"id": "ASC"})
113
     */
114
    private Collection $comments;
115
116
    /**
117
     *
118
     * @ManyToOne(targetEntity="RpgPlotArchiv", inversedBy="posts")
119
     * @JoinColumn(name="plot_id", referencedColumnName="id")
120
     */
121
    private ?RpgPlotArchivInterface $rpgPlot = null;
122
123
    public function __construct()
124
    {
125
        $this->comments = new ArrayCollection();
126
    }
127
128
    public function getId(): int
129
    {
130
        return $this->id;
131
    }
132
133
    public function getVersion(): ?string
134
    {
135
        return $this->version;
136
    }
137
138
    public function getFormerId(): int
139
    {
140
        return $this->former_id;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->former_id could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
141
    }
142
143
    public function getTitle(): ?string
144
    {
145
        return $this->titel;
146
    }
147
148
    public function setTitle(string $title): KnPostArchivInterface
149
    {
150
        $this->titel = $title;
151
152
        return $this;
153
    }
154
155
    public function getText(): string
156
    {
157
        return $this->text;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->text could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
158
    }
159
160
    public function setText(string $text): KnPostArchivInterface
161
    {
162
        $this->text = $text;
163
164
        return $this;
165
    }
166
167
    public function getDate(): int
168
    {
169
        return $this->date;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->date could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
170
    }
171
172
    public function setDate(int $date): KnPostArchivInterface
173
    {
174
        $this->date = $date;
175
176
        return $this;
177
    }
178
179
    public function getUsername(): string
180
    {
181
        return $this->username;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->username could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
182
    }
183
184
    public function setUsername(string $username): KnPostArchivInterface
185
    {
186
        $this->username = $username;
187
188
        return $this;
189
    }
190
191
    public function getUserId(): ?int
192
    {
193
        return $this->user_id;
194
    }
195
196
    public function getdelUserId(): ?int
197
    {
198
        return $this->del_user_id;
199
    }
200
201
    public function setdelUserId(?int $userid): KnPostArchivInterface
202
    {
203
        $this->del_user_id = $userid;
204
205
        return $this;
206
    }
207
208
    public function getEditDate(): int
209
    {
210
        return $this->lastedit;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->lastedit could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
211
    }
212
213
    public function setEditDate(int $editDate): KnPostArchivInterface
214
    {
215
        $this->lastedit = $editDate;
216
217
        return $this;
218
    }
219
220
    public function getPlotId(): ?int
221
    {
222
        return $this->plot_id;
223
    }
224
225
    public function getRpgPlot(): ?RpgPlotArchivInterface
226
    {
227
        return $this->rpgPlot;
228
    }
229
230
    public function setRpgPlot(?RpgPlotArchivInterface $rpgPlot): KnPostArchivInterface
231
    {
232
        $this->rpgPlot = $rpgPlot;
233
234
        return $this;
235
    }
236
237
    public function getComments(): Collection
238
    {
239
        return $this->comments;
240
    }
241
242
    public function getRatings(): array
243
    {
244
        return $this->ratings;
245
    }
246
247
    public function setRatings(array $ratings): KnPostArchivInterface
248
    {
249
        $this->ratings = $ratings;
250
        return $this;
251
    }
252
253
    public function getUrl(): string
254
    {
255
        return sprintf(
256
            '/comm.php?%s=1&id=%d',
257
            ShowSingleKn::VIEW_IDENTIFIER,
258
            $this->getId()
259
        );
260
    }
261
}
262