Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| DocumentationPageParser | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| execute | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Hyde\Framework\Models\Parsers; |
| 4 | |
| 5 | use Hyde\Framework\Contracts\AbstractPageParser; |
| 6 | use Hyde\Framework\Hyde; |
| 7 | use Hyde\Framework\Models\DocumentationPage; |
| 8 | use Hyde\Framework\Services\MarkdownFileService; |
| 9 | |
| 10 | class DocumentationPageParser extends AbstractPageParser |
| 11 | { |
| 12 | protected string $pageModel = DocumentationPage::class; |
| 13 | protected string $slug; |
| 14 | |
| 15 | public string $title; |
| 16 | public string $body; |
| 17 | |
| 18 | public function execute(): void |
| 19 | { |
| 20 | $document = (new MarkdownFileService( |
| 21 | Hyde::getDocumentationPagePath("/$this->slug.md") |
| 22 | ))->get(); |
| 23 | |
| 24 | $this->title = $document->findTitleForDocument(); |
| 25 | |
| 26 | $this->body = $document->body; |
| 27 | } |
| 28 | |
| 29 | public function get(): DocumentationPage |
| 30 | { |
| 31 | return new DocumentationPage( |
| 32 | matter: [], |
| 33 | body: $this->body, |
| 34 | title: $this->title, |
| 35 | slug: $this->slug |
| 36 | ); |
| 37 | } |
| 38 | } |