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