Passed
Push — master ( 91454b...2408fc )
by Nico
22:07 queued 10:43
created

KnPost::getHref()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 2
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 Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Stu\Component\Game\ModuleViewEnum;
21
use Stu\Module\Communication\View\ShowSingleKn\ShowSingleKn;
22
use Stu\Orm\Repository\KnPostRepository;
23
24
#[Table(name: 'stu_kn')]
25
#[Index(name: 'plot_idx', columns: ['plot_id'])]
26
#[Index(name: 'kn_post_date_idx', columns: ['date'])]
27
#[Index(name: 'kn_post_user_idx', columns: ['user_id'])]
28
#[Entity(repositoryClass: KnPostRepository::class)]
29
class KnPost implements KnPostInterface
30
{
31
    #[Id]
32
    #[Column(type: 'integer')]
33
    #[GeneratedValue(strategy: 'IDENTITY')]
34
    private int $id;
35
36
    #[Column(type: 'string', nullable: true)]
37
    private ?string $titel = '';
38
39
    #[Column(type: 'text')]
40
    private string $text = '';
41
42
    #[Column(type: 'integer')]
43
    private int $date = 0;
44
45
    #[Column(type: 'string')]
46
    private string $username = '';
47
48
    #[Column(type: 'integer', nullable: true)]
49
    private ?int $user_id = 0;
50
51
    #[Column(type: 'integer', nullable: true)]
52
    private ?int $del_user_id = 0;
53
54
    #[Column(type: 'integer')]
55
    private int $lastedit = 0;
56
57
    #[Column(type: 'integer', nullable: true)]
58
    private ?int $plot_id = null;
59
60
    /**
61
     * @var array<mixed>
62
     */
63
    #[Column(type: 'json')]
64
    private array $ratings = [];
65
66
    /**
67
     * @var ArrayCollection<int, KnCommentInterface>
68
     */
69
    #[OneToMany(targetEntity: 'KnComment', mappedBy: 'post')]
70
    #[OrderBy(['id' => 'ASC'])]
71
    private Collection $comments;
72
73
    /**
74
     * @var ArrayCollection<int, KnCharacterInterface>
75
     */
76
    #[OneToMany(targetEntity: 'KnCharacter', mappedBy: 'knPost')]
77
    private Collection $knCharacters;
78
79
80
    #[ManyToOne(targetEntity: 'RpgPlot', inversedBy: 'posts')]
81
    #[JoinColumn(name: 'plot_id', referencedColumnName: 'id')]
82
    private ?RpgPlotInterface $rpgPlot = null;
83
84
    #[ManyToOne(targetEntity: 'User')]
85
    #[JoinColumn(name: 'user_id', referencedColumnName: 'id')]
86
    private UserInterface $user;
87
88
89
    public function __construct()
90
    {
91
        $this->comments = new ArrayCollection();
92
        $this->knCharacters = new ArrayCollection();
93
    }
94
95 5
    #[Override]
96
    public function getId(): int
97
    {
98 5
        return $this->id;
99
    }
100
101 3
    #[Override]
102
    public function getTitle(): ?string
103
    {
104 3
        return $this->titel;
105
    }
106
107
    #[Override]
108
    public function setTitle(string $title): KnPostInterface
109
    {
110
        $this->titel = $title;
111
112
        return $this;
113
    }
114
115 3
    #[Override]
116
    public function getText(): string
117
    {
118 3
        return $this->text;
119
    }
120
121
    #[Override]
122
    public function setText(string $text): KnPostInterface
123
    {
124
        $this->text = $text;
125
126
        return $this;
127
    }
128
129 5
    #[Override]
130
    public function getDate(): int
131
    {
132 5
        return $this->date;
133
    }
134
135
    #[Override]
136
    public function setDate(int $date): KnPostInterface
137
    {
138
        $this->date = $date;
139
140
        return $this;
141
    }
142
143 3
    #[Override]
144
    public function getUsername(): string
145
    {
146 3
        return $this->username;
147
    }
148
149
    #[Override]
150
    public function setUsername(string $username): KnPostInterface
151
    {
152
        $this->username = $username;
153
154
        return $this;
155
    }
156
157 4
    #[Override]
158
    public function getUserId(): int
159
    {
160 4
        return $this->user_id;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->user_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...
161
    }
162
163
    #[Override]
164
    public function getdelUserId(): ?int
165
    {
166
        return $this->del_user_id;
167
    }
168
169
    #[Override]
170
    public function setdelUserId(?int $userid): KnPostInterface
171
    {
172
        $this->del_user_id = $userid;
173
174
        return $this;
175
    }
176
177 4
    #[Override]
178
    public function getUser(): UserInterface
179
    {
180 4
        return $this->user;
181
    }
182
183
    #[Override]
184
    public function setUser(UserInterface $user): KnPostInterface
185
    {
186
        $this->user = $user;
187
        return $this;
188
    }
189
190 3
    #[Override]
191
    public function getEditDate(): int
192
    {
193 3
        return $this->lastedit;
194
    }
195
196
    #[Override]
197
    public function setEditDate(int $editDate): KnPostInterface
198
    {
199
        $this->lastedit = $editDate;
200
201
        return $this;
202
    }
203
204
    #[Override]
205
    public function getPlotId(): ?int
206
    {
207
        return $this->plot_id;
208
    }
209
210 4
    #[Override]
211
    public function getRpgPlot(): ?RpgPlotInterface
212
    {
213 4
        return $this->rpgPlot;
214
    }
215
216
    #[Override]
217
    public function setRpgPlot(?RpgPlotInterface $rpgPlot): KnPostInterface
218
    {
219
        $this->rpgPlot = $rpgPlot;
220
221
        return $this;
222
    }
223
224 1
    #[Override]
225
    public function getComments(): Collection
226
    {
227 1
        return $this->comments;
228
    }
229
230 3
    #[Override]
231
    public function getRatings(): array
232
    {
233 3
        return $this->ratings;
234
    }
235
236
    #[Override]
237
    public function setRatings(array $ratings): KnPostInterface
238
    {
239
        $this->ratings = $ratings;
240
        return $this;
241
    }
242
243
    #[Override]
244
    public function getUrl(): string
245
    {
246
        return sprintf(
247
            '/comm.php?%s=1&knid=%d',
248
            ShowSingleKn::VIEW_IDENTIFIER,
249
            $this->getId()
250
        );
251
    }
252
253
    /**
254
     * @return Collection<int, KnCharacterInterface>
255
     */
256 3
    #[Override]
257
    public function getKnCharacters(): Collection
258
    {
259 3
        return $this->knCharacters;
260
    }
261
262
    #[Override]
263
    public function getHref(): string
264
    {
265
        return sprintf(
266
            '%s?%s=1&knid=%d',
267
            ModuleViewEnum::COMMUNICATION->getPhpPage(),
268
            ShowSingleKn::VIEW_IDENTIFIER,
269
            $this->getId()
270
        );
271
    }
272
}
273