Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 54
0.00% covered (danger)
0.00%
0 / 46
CRAP
0.00% covered (danger)
0.00%
0 / 1
TerminTemplate
0.00% covered (danger)
0.00%
0 / 54
0.00% covered (danger)
0.00%
0 / 46
2450
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getStartTime
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setStartTime
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDurationSeconds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDurationSeconds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDeadlineEarlierSeconds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDeadlineEarlierSeconds
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDeadlineTime
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDeadlineTime
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getShouldPromote
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setShouldPromote
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOrganizerUser
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setOrganizerUser
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMinParticipants
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMinParticipants
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMaxParticipants
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMaxParticipants
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMinVolunteers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMinVolunteers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMaxVolunteers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setMaxVolunteers
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLabels
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addLabel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 removeLabel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 clearLabels
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLocation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setLocation
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getNewsletter
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setNewsletter
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getImageIds
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
 setImageIds
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 testOnlyGetField
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityNameForStorage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getEntityIdForStorage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIdFieldNameForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getIdForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTitleForSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCriteriaForFilter
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getCriteriaForQuery
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Entity\Termine;
4
5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\Common\Collections\Collection;
7use Doctrine\Common\Collections\Criteria;
8use Doctrine\Common\Collections\Expr\Expression;
9use Doctrine\ORM\Mapping as ORM;
10use Olz\Entity\Common\DataStorageInterface;
11use Olz\Entity\Common\DataStorageTrait;
12use Olz\Entity\Common\OlzEntity;
13use Olz\Entity\Common\SearchableInterface;
14use Olz\Entity\Common\TestableInterface;
15use Olz\Entity\Users\User;
16use Olz\Repository\Termine\TerminTemplateRepository;
17
18#[ORM\Table(name: 'termin_templates')]
19#[ORM\Entity(repositoryClass: TerminTemplateRepository::class)]
20class TerminTemplate extends OlzEntity implements DataStorageInterface, SearchableInterface, TestableInterface {
21    use DataStorageTrait;
22
23    #[ORM\Id]
24    #[ORM\Column(type: 'integer', nullable: false)]
25    #[ORM\GeneratedValue]
26    private int $id;
27
28    #[ORM\Column(type: 'time', nullable: true)]
29    private ?\DateTime $start_time;
30
31    #[ORM\Column(type: 'integer', nullable: true)]
32    private ?int $duration_seconds;
33
34    #[ORM\Column(type: 'integer', nullable: true)]
35    private ?int $deadline_earlier_seconds;
36
37    #[ORM\Column(type: 'time', nullable: true)]
38    private ?\DateTime $deadline_time;
39
40    #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => 0])]
41    private bool $should_promote;
42
43    #[ORM\ManyToOne(targetEntity: User::class)]
44    #[ORM\JoinColumn(name: 'organizer_user_id', referencedColumnName: 'id', nullable: true)]
45    protected ?User $organizer_user;
46
47    // TODO: Participants registration template
48
49    #[ORM\Column(type: 'integer', nullable: true)]
50    private ?int $min_participants;
51
52    #[ORM\Column(type: 'integer', nullable: true)]
53    private ?int $max_participants;
54
55    // TODO: Volunteers registration template
56
57    #[ORM\Column(type: 'integer', nullable: true)]
58    private ?int $min_volunteers;
59
60    #[ORM\Column(type: 'integer', nullable: true)]
61    private ?int $max_volunteers;
62
63    #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => 0])]
64    private bool $newsletter;
65
66    #[ORM\Column(type: 'text', nullable: true)]
67    private ?string $title;
68
69    #[ORM\Column(type: 'text', nullable: true)]
70    private ?string $text;
71
72    /** @var Collection<int|string, TerminLabel>&iterable<TerminLabel> */
73    #[ORM\JoinTable(name: 'termin_template_label_map')]
74    #[ORM\JoinColumn(name: 'termin_template_id', referencedColumnName: 'id')]
75    #[ORM\InverseJoinColumn(name: 'label_id', referencedColumnName: 'id')]
76    #[ORM\ManyToMany(targetEntity: TerminLabel::class, inversedBy: 'termin_templates')]
77    private Collection $labels;
78
79    #[ORM\ManyToOne(targetEntity: TerminLocation::class)]
80    #[ORM\JoinColumn(name: 'location_id', referencedColumnName: 'id', nullable: true)]
81    private ?TerminLocation $location;
82
83    #[ORM\Column(type: 'text', nullable: true)]
84    private ?string $image_ids;
85
86    public function __construct() {
87        $this->labels = new ArrayCollection();
88    }
89
90    public function getId(): ?int {
91        return $this->id ?? null;
92    }
93
94    public function setId(int $new_value): void {
95        $this->id = $new_value;
96    }
97
98    public function getStartTime(): ?\DateTime {
99        return $this->start_time;
100    }
101
102    public function setStartTime(?\DateTime $new_value): void {
103        $this->start_time = $new_value;
104    }
105
106    public function getDurationSeconds(): ?int {
107        return $this->duration_seconds;
108    }
109
110    public function setDurationSeconds(?int $new_value): void {
111        $this->duration_seconds = $new_value;
112    }
113
114    public function getDeadlineEarlierSeconds(): ?int {
115        return $this->deadline_earlier_seconds;
116    }
117
118    public function setDeadlineEarlierSeconds(?int $new_value): void {
119        $this->deadline_earlier_seconds = $new_value;
120    }
121
122    public function getDeadlineTime(): ?\DateTime {
123        return $this->deadline_time;
124    }
125
126    public function setDeadlineTime(?\DateTime $new_value): void {
127        $this->deadline_time = $new_value;
128    }
129
130    public function getShouldPromote(): bool {
131        return $this->should_promote;
132    }
133
134    public function setShouldPromote(bool $new_value): void {
135        $this->should_promote = $new_value;
136    }
137
138    public function getOrganizerUser(): ?User {
139        return $this->organizer_user;
140    }
141
142    public function setOrganizerUser(?User $new_value): void {
143        $this->organizer_user = $new_value;
144    }
145
146    public function getMinParticipants(): ?int {
147        return $this->min_participants;
148    }
149
150    public function setMinParticipants(?int $new_value): void {
151        $this->min_participants = $new_value;
152    }
153
154    public function getMaxParticipants(): ?int {
155        return $this->max_participants;
156    }
157
158    public function setMaxParticipants(?int $new_value): void {
159        $this->max_participants = $new_value;
160    }
161
162    public function getMinVolunteers(): ?int {
163        return $this->min_volunteers;
164    }
165
166    public function setMinVolunteers(?int $new_value): void {
167        $this->min_volunteers = $new_value;
168    }
169
170    public function getMaxVolunteers(): ?int {
171        return $this->max_volunteers;
172    }
173
174    public function setMaxVolunteers(?int $new_value): void {
175        $this->max_volunteers = $new_value;
176    }
177
178    public function getTitle(): ?string {
179        return $this->title;
180    }
181
182    public function setTitle(?string $new_value): void {
183        $this->title = $new_value;
184    }
185
186    public function getText(): ?string {
187        return $this->text;
188    }
189
190    public function setText(?string $new_value): void {
191        $this->text = $new_value;
192    }
193
194    /** @return Collection<int|string, TerminLabel>&iterable<TerminLabel> */
195    public function getLabels(): Collection {
196        return $this->labels;
197    }
198
199    public function addLabel(TerminLabel $label): void {
200        $this->labels->add($label);
201    }
202
203    public function removeLabel(TerminLabel $label): void {
204        $this->labels->removeElement($label);
205    }
206
207    public function clearLabels(): void {
208        $this->labels->clear();
209    }
210
211    public function getLocation(): ?TerminLocation {
212        return $this->location;
213    }
214
215    public function setLocation(?TerminLocation $new_value): void {
216        $this->location = $new_value;
217    }
218
219    public function getNewsletter(): bool {
220        return $this->newsletter;
221    }
222
223    public function setNewsletter(bool $new_value): void {
224        $this->newsletter = $new_value;
225    }
226
227    /** @return array<string> */
228    public function getImageIds(): array {
229        if ($this->image_ids == null) {
230            return [];
231        }
232        $array = json_decode($this->image_ids, true);
233        return is_array($array) ? $array : [];
234    }
235
236    /** @param array<string> $new_value */
237    public function setImageIds(array $new_value): void {
238        $enc_value = json_encode($new_value);
239        if (!$enc_value) {
240            return;
241        }
242        $this->image_ids = $enc_value;
243    }
244
245    // ---
246
247    public function __toString(): string {
248        return "TerminTemplate (ID: {$this->getId()})";
249    }
250
251    public function testOnlyGetField(string $field_name): mixed {
252        return $this->{$field_name};
253    }
254
255    public static function getEntityNameForStorage(): string {
256        return 'termin_templates';
257    }
258
259    public function getEntityIdForStorage(): string {
260        return "{$this->getId()}";
261    }
262
263    public static function getIdFieldNameForSearch(): string {
264        return 'id';
265    }
266
267    public function getIdForSearch(): int {
268        return $this->getId() ?? 0;
269    }
270
271    public function getTitleForSearch(): string {
272        return $this->getTitle() ?? '';
273    }
274
275    public static function getCriteriaForFilter(string $key, string $value): Expression {
276        throw new \Exception("No such TerminTemplate filter: {$key}");
277    }
278
279    public static function getCriteriaForQuery(string $query): Expression {
280        return Criteria::expr()->orX(
281            Criteria::expr()->contains('title', $query),
282        );
283    }
284}