Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
84.44% covered (warning)
84.44%
38 / 45
86.49% covered (warning)
86.49%
32 / 37
CRAP
0.00% covered (danger)
0.00%
0 / 1
NewsEntry
84.44% covered (warning)
84.44%
38 / 45
86.49% covered (warning)
86.49%
32 / 37
48.64
0.00% covered (danger)
0.00%
0 / 1
 id
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPublishedDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPublishedDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPublishedTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setPublishedTime
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getFormat
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setFormat
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthorName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAuthorName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthorEmail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAuthorEmail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthorUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAuthorUser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAuthorRole
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAuthorRole
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTitle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTitle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTeaser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTeaser
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getImageIds
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
3.14
 setImageIds
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 getTags
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTags
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExternalUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setExternalUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTermin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setTermin
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCounter
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setCounter
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNewsletter
n/a
0 / 0
n/a
0 / 0
1
 setNewsletter
n/a
0 / 0
n/a
0 / 0
1
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 testOnlyGetField
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEntityNameForStorage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEntityIdForStorage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Olz\Entity\News;
4
5use Doctrine\ORM\Mapping as ORM;
6use Olz\Entity\Common\DataStorageInterface;
7use Olz\Entity\Common\DataStorageTrait;
8use Olz\Entity\Common\OlzEntity;
9use Olz\Entity\Common\TestableInterface;
10use Olz\Entity\Roles\Role;
11use Olz\Entity\Termine\Termin;
12use Olz\Entity\Users\User;
13use Olz\Repository\News\NewsRepository;
14
15#[ORM\Table(name: 'news')]
16#[ORM\Index(name: 'published_index', columns: ['published_date', 'published_time'])]
17#[ORM\Entity(repositoryClass: NewsRepository::class)]
18class NewsEntry extends OlzEntity implements DataStorageInterface, TestableInterface {
19    use DataStorageTrait;
20
21    #[ORM\Id]
22    #[ORM\Column(type: 'integer', nullable: false)]
23    #[ORM\GeneratedValue]
24    private int $id;
25
26    #[ORM\ManyToOne(targetEntity: Termin::class)]
27    #[ORM\JoinColumn(name: 'termin_id', referencedColumnName: 'id', nullable: true)]
28    private ?Termin $termin;
29
30    #[ORM\Column(type: 'date', nullable: false)]
31    private \DateTime $published_date;
32
33    #[ORM\Column(type: 'time', nullable: true)]
34    private ?\DateTime $published_time;
35
36    #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => 1])]
37    private bool $newsletter;
38
39    #[ORM\Column(type: 'text', nullable: false)]
40    private string $title;
41
42    #[ORM\Column(type: 'text', nullable: true)]
43    private ?string $teaser;
44
45    #[ORM\Column(type: 'text', nullable: true)]
46    private ?string $content;
47
48    #[ORM\Column(type: 'text', nullable: true)]
49    private ?string $image_ids;
50
51    #[ORM\Column(type: 'text', nullable: true)]
52    private ?string $external_url;
53
54    #[ORM\Column(type: 'string', nullable: true)]
55    private ?string $author_name;
56
57    #[ORM\Column(type: 'string', nullable: true)]
58    private ?string $author_email;
59
60    #[ORM\ManyToOne(targetEntity: User::class)]
61    #[ORM\JoinColumn(name: 'author_user_id', referencedColumnName: 'id', nullable: true)]
62    private ?User $author_user;
63
64    #[ORM\ManyToOne(targetEntity: Role::class)]
65    #[ORM\JoinColumn(name: 'author_role_id', referencedColumnName: 'id', nullable: true)]
66    private ?Role $author_role;
67
68    #[ORM\Column(type: 'text', nullable: false)]
69    private string $format;
70
71    #[ORM\Column(type: 'text', nullable: false, options: ['default' => ''])]
72    private string $tags;
73
74    #[ORM\Column(type: 'integer', nullable: false, options: ['default' => 0])]
75    private int $counter;
76    // PRIMARY KEY (`id`),
77    // KEY `datum` (`datum`)
78
79    public static function id(int $id): self {
80        $entity = new self();
81        $entity->setId($id);
82        return $entity;
83    }
84
85    public function getId(): ?int {
86        return $this->id ?? null;
87    }
88
89    public function setId(int $new_value): void {
90        $this->id = $new_value;
91    }
92
93    public function getPublishedDate(): \DateTime {
94        return $this->published_date;
95    }
96
97    public function setPublishedDate(\DateTime $new_value): void {
98        $this->published_date = $new_value;
99    }
100
101    public function getPublishedTime(): ?\DateTime {
102        return $this->published_time;
103    }
104
105    public function setPublishedTime(?\DateTime $new_value): void {
106        $this->published_time = $new_value;
107    }
108
109    public function getFormat(): string {
110        return $this->format;
111    }
112
113    public function setFormat(string $new_value): void {
114        $this->format = $new_value;
115    }
116
117    public function getAuthorName(): ?string {
118        return $this->author_name;
119    }
120
121    public function setAuthorName(?string $new_value): void {
122        $this->author_name = $new_value;
123    }
124
125    public function getAuthorEmail(): ?string {
126        return $this->author_email;
127    }
128
129    public function setAuthorEmail(?string $new_value): void {
130        $this->author_email = $new_value;
131    }
132
133    public function getAuthorUser(): ?User {
134        return $this->author_user;
135    }
136
137    public function setAuthorUser(?User $new_value): void {
138        $this->author_user = $new_value;
139    }
140
141    public function getAuthorRole(): ?Role {
142        return $this->author_role;
143    }
144
145    public function setAuthorRole(?Role $new_value): void {
146        $this->author_role = $new_value;
147    }
148
149    public function getTitle(): string {
150        return $this->title;
151    }
152
153    public function setTitle(string $new_value): void {
154        $this->title = $new_value;
155    }
156
157    public function getTeaser(): ?string {
158        return $this->teaser;
159    }
160
161    public function setTeaser(?string $new_value): void {
162        $this->teaser = $new_value;
163    }
164
165    public function getContent(): ?string {
166        return $this->content;
167    }
168
169    public function setContent(?string $new_value): void {
170        $this->content = $new_value;
171    }
172
173    /** @return array<string> */
174    public function getImageIds(): array {
175        if ($this->image_ids == null) {
176            return [];
177        }
178        $array = json_decode($this->image_ids, true);
179        return is_array($array) ? $array : [];
180    }
181
182    /** @param array<string> $new_value */
183    public function setImageIds(array $new_value): void {
184        $enc_value = json_encode($new_value);
185        if (!$enc_value) {
186            return;
187        }
188        $this->image_ids = $enc_value;
189    }
190
191    public function getTags(): string {
192        return $this->tags;
193    }
194
195    public function setTags(string $new_value): void {
196        $this->tags = $new_value;
197    }
198
199    public function getExternalUrl(): ?string {
200        return $this->external_url;
201    }
202
203    public function setExternalUrl(?string $new_value): void {
204        $this->external_url = $new_value;
205    }
206
207    public function getTermin(): ?Termin {
208        return $this->termin;
209    }
210
211    public function setTermin(?Termin $new_value): void {
212        $this->termin = $new_value;
213    }
214
215    public function getCounter(): int {
216        return $this->counter;
217    }
218
219    public function setCounter(int $new_value): void {
220        $this->counter = $new_value;
221    }
222
223    /** @deprecated */
224    public function getNewsletter(): bool {
225        return $this->newsletter;
226    }
227
228    /** @deprecated */
229    public function setNewsletter(bool $new_value): void {
230        $this->newsletter = $new_value;
231    }
232
233    // ---
234
235    public function __toString(): string {
236        return "NewsEntry (ID: {$this->getId()})";
237    }
238
239    public function testOnlyGetField(string $field_name): mixed {
240        return $this->{$field_name};
241    }
242
243    public static function getEntityNameForStorage(): string {
244        return 'news';
245    }
246
247    public function getEntityIdForStorage(): string {
248        return "{$this->getId()}";
249    }
250}