*/ #[ OA\Property(type: "array", items: new OA\Items()), ORM\OneToMany(mappedBy: 'streamer', targetEntity: StationSchedule::class), DeepNormalize(true), Serializer\MaxDepth(1) ] protected Collection $schedule_items; public function __construct(Station $station) { $this->station = $station; $this->schedule_items = new ArrayCollection(); } public function getStation(): Station { return $this->station; } public function setStation(Station $station): void { $this->station = $station; } public function getStreamerUsername(): string { return $this->streamer_username; } public function setStreamerUsername(string $streamer_username): void { $this->streamer_username = $this->truncateString($streamer_username, 50); } public function getStreamerPassword(): string { return ''; } public function setStreamerPassword(?string $streamer_password): void { $streamer_password = trim($streamer_password ?? ''); if (!empty($streamer_password)) { $this->streamer_password = password_hash($streamer_password, PASSWORD_ARGON2ID); } } public function authenticate(string $password): bool { return password_verify($password, $this->streamer_password); } public function getDisplayName(): string { return (!empty($this->display_name)) ? $this->display_name : $this->streamer_username; } public function setDisplayName(?string $display_name): void { $this->display_name = $this->truncateNullableString($display_name); } public function getComments(): ?string { return $this->comments; } public function setComments(string $comments = null): void { $this->comments = $comments; } public function getIsActive(): bool { return $this->is_active; } public function setIsActive(bool $is_active): void { $this->is_active = $is_active; // Automatically set the "reactivate_at" flag to null if the DJ is for any reason reactivated. if (true === $is_active) { $this->reactivate_at = null; } } public function enforceSchedule(): bool { return $this->enforce_schedule; } public function setEnforceSchedule(bool $enforce_schedule): void { $this->enforce_schedule = $enforce_schedule; } public function getReactivateAt(): ?int { return $this->reactivate_at; } public function setReactivateAt(?int $reactivate_at): void { $this->reactivate_at = $reactivate_at; } public function deactivateFor(int $seconds): void { $this->is_active = false; $this->reactivate_at = time() + $seconds; } public function getArtUpdatedAt(): int { return $this->art_updated_at; } public function setArtUpdatedAt(int $art_updated_at): self { $this->art_updated_at = $art_updated_at; return $this; } /** * @return Collection */ public function getScheduleItems(): Collection { return $this->schedule_items; } public function __toString(): string { return $this->getStation() . ' Streamer: ' . $this->getDisplayName(); } public function __clone() { $this->reactivate_at = null; } public static function getArtworkPath(int|string $streamer_id): string { return 'streamer_' . $streamer_id . '.jpg'; } }