tex/src/Document.php

48 lines
1016 B
PHP

<?php
namespace Zoomyboy\Tex;
use PHPUnit\Framework\Assert;
abstract class Document
{
abstract public function basename(): string;
abstract public function view(): string;
abstract public function template(): ?Template;
abstract public function getEngine(): Engine;
public function renderBody(): string
{
return view()
->make($this->view(), get_object_vars($this))
->render();
}
public function assertHasContent(string $content): void
{
Assert::assertStringContainsString(
$content,
$this->renderBody(),
"Failed asserting that Content contains {$content}"
);
}
public function hasContent(string $content): bool
{
return str_contains($this->renderBody(), $content);
}
public function filename(): string
{
return $this->basename().'.tex';
}
public function compiledFilename(): string
{
return $this->basename().'.pdf';
}
}