Skip to content

Commit

Permalink
Merge pull request #522 from hydephp/refactor-page-constructors
Browse files Browse the repository at this point in the history
Refactor page constructors hydephp/develop@d461716
  • Loading branch information
github-actions committed Sep 14, 2022
1 parent ef17c0c commit 2577bc2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Actions/SourceFileParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ public function __construct(string $pageClass, string $identifier)
$this->validateExistence($pageClass, $identifier);
$this->identifier = $identifier;

$this->page = $pageClass === BladePage::class
? $this->parseBladePage()
: $this->parseMarkdownPage($pageClass);
$this->page = $this->constructPage($pageClass);
}

protected function parseBladePage(): BladePage
{
return new BladePage(
$this->identifier,
(BladeMatterParser::parseFile(BladePage::sourcePath($this->identifier)))
BladeMatterParser::parseFile(BladePage::sourcePath($this->identifier))
);
}

Expand All @@ -61,4 +59,13 @@ public function get(): HydePage
{
return $this->page;
}

protected function constructPage(string $pageClass): BladePage|BaseMarkdownPage
{
if ($pageClass === BladePage::class) {
return $this->parseBladePage();
}

return $this->parseMarkdownPage($pageClass);
}
}

0 comments on commit 2577bc2

Please sign in to comment.