Some checks failed
Push image to registry / build-image (push) Failing after 4m19s
52 lines
1.3 KiB
PHP
52 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 $body;
|
|
private ?string $error;
|
|
private bool $hasScreenshot;
|
|
|
|
public function __construct(Job $job, string $body, string $error = null, bool $hasScreenshot = false) {
|
|
$this->job = $job;
|
|
$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();
|
|
}
|
|
}
|