Files
DatBrowser/app/Notification/NotificationBody/JobDebugNotificationBody.php
Matthias Guillitte fec63ff249
Some checks failed
Push image to registry / build-image (push) Failing after 3m41s
Added Debug notifications
2025-03-02 10:03:27 +01:00

54 lines
1.3 KiB
PHP

<?php
namespace App\Notification\NotificationBody;
use App\Models\Job;
use App\Notification\NotificationBody;
use App\Notification\Stringifiable;
class JobDebugNotificationBody extends NotificationBody {
private Job $job;
private string $title;
private string $body;
private string $error;
private bool $hasScreenshot;
public function __construct(Job $job, string $title, string $body, string $error, bool $hasScreenshot = false) {
$this->job = $job;
$this->title = $title;
$this->body = $body;
$this->error = $error;
$this->hasScreenshot = $hasScreenshot;
}
private function constructString(bool $inMarkdown = false) {
$mdBody = "";
if ($this->body !== null) {
$mdBody .= $this->body;
}
if ($this->error !== null) {
$errorWrapper = $inMarkdown ? "```" : "";
$mdBody .= " :\n" . $errorWrapper . $this->error . $errorWrapper;
}
if ($inMarkdown && $this->hasScreenshot) {
$mdBody .= "\nScreenshot : ";
}
return $mdBody;
}
/**
* @inheritDoc
*/
public function toMarkdownString(): string {
return $this->constructString(true);
}
/**
* @inheritDoc
*/
public function toString(): string {
return $this->constructString();
}
}