Passed
Push — master ( 0f8d9d...85764f )
by Caen
03:45 queued 15s
created

DocumentationSearchPage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 3
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework\Features\Documentation;
6
7
use Hyde\Framework\Actions\StaticPageBuilder;
8
use Hyde\Hyde;
9
use Hyde\Pages\DocumentationPage;
10
11
/**
12
 * @internal This page is used to render the search page for the documentation.
13
 *
14
 * It is not based on a source file, but is dynamically generated when the Search feature is enabled.
15
 * If you want to override this page, you can create a page with the route key "docs/search",
16
 * then this class will not be applied. For example, `_pages/docs/search.blade.php`.
17
 *
18
 * @see \Hyde\Framework\Testing\Feature\DocumentationSearchPageTest
19
 */
20
class DocumentationSearchPage extends DocumentationPage
21
{
22
    public function __construct()
23
    {
24
        parent::__construct(DocumentationPage::outputDirectory().'/search', [
25
            'title' => 'Search',
26
        ]);
27
    }
28
29
    public static function enabled(): bool
30
    {
31
        return config('docs.create_search_page', true) && ! Hyde::routes()->has('docs/search');
32
    }
33
34
    public static function generate(): string
35
    {
36
        return (new StaticPageBuilder(new static()))->__invoke();
37
    }
38
39
    public function compile(): string
40
    {
41
        return view('hyde::pages.documentation-search')->render();
42
    }
43
}
44