Passed
Push — master ( 940f24...228741 )
by Caen
03:44 queued 13s
created

DocumentationPage::home()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Hyde\Framework\Models\Pages;
4
5
use Hyde\Framework\Concerns\HasTableOfContents;
6
use Hyde\Framework\Contracts\AbstractMarkdownPage;
7
use Hyde\Framework\Contracts\RouteContract;
8
use Hyde\Framework\Models\Parsers\DocumentationPageParser;
9
use Hyde\Framework\Models\Route;
10
11
class DocumentationPage extends AbstractMarkdownPage
12
{
13
    use HasTableOfContents;
14
15
    public static string $sourceDirectory = '_docs';
16
    public static string $outputDirectory = 'docs';
17
18
    public static string $parserClass = DocumentationPageParser::class;
19
20
    public function __construct(array $matter = [], string $body = '', string $title = '', string $slug = '')
21
    {
22
        parent::__construct($matter, $body, $title, $slug);
23
    }
24
25
    /** @internal */
26
    public function getOnlineSourcePath(): string|false
27
    {
28
        if (config('docs.source_file_location_base') === null) {
29
            return false;
30
        }
31
32
        return trim(config('docs.source_file_location_base'), '/').'/'.$this->slug.'.md';
33
    }
34
35
    public static function home(): ?RouteContract
36
    {
37
        return Route::exists('docs/index') ? Route::get('docs/index') : null;
38
    }
39
}
40