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