diff --git a/src/StaticPage.php b/src/StaticPage.php index bf0876ccf5ca2afd4a04b1282800d2426e621d10..15678028367544072cd823cb24c9184bccad02db 100644 --- a/src/StaticPage.php +++ b/src/StaticPage.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Distantmagic\Resonance; use Distantmagic\Resonance\InputValidatedData\FrontMatter; +use RuntimeException; use Symfony\Component\Finder\SplFileInfo; readonly class StaticPage @@ -25,12 +26,21 @@ readonly class StaticPage return mb_strtolower($this->frontMatter->title) <=> mb_strtolower($other->frontMatter->title); } + /** + * @return non-empty-string + */ public function getBasename(): string { $relativePath = $this->file->getRelativePath(); if (empty($relativePath)) { - return $this->file->getFilenameWithoutExtension(); + $filename = $this->file->getFilenameWithoutExtension(); + + if (empty($filename)) { + throw new RuntimeException('Unable to determine filename'); + } + + return $filename; } return sprintf( @@ -40,6 +50,9 @@ readonly class StaticPage ); } + /** + * @return non-empty-string + */ public function getHref(): string { if ('index' === $this->file->getFilenameWithoutExtension()) { @@ -55,6 +68,9 @@ readonly class StaticPage return '/'.$this->getBasename().'.html'; } + /** + * @return non-empty-string + */ public function getOutputDirectory(): string { return sprintf( @@ -64,6 +80,9 @@ readonly class StaticPage ); } + /** + * @return non-empty-string + */ public function getOutputPathname(): string { return sprintf(