Passed
Push — master ( 32a4a2...da9bd5 )
by Caen
04:12 queued 14s
created

StaticPageBuilder::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 11
rs 10
c 5
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework\Actions;
6
7
use Hyde\Hyde;
8
use Hyde\Facades\Filesystem;
9
use Hyde\Framework\Concerns\InteractsWithDirectories;
10
use Hyde\Pages\Concerns\HydePage;
11
12
/**
13
 * Converts a Page Model into a static HTML page.
14
 *
15
 * @see \Hyde\Framework\Testing\Feature\StaticPageBuilderTest
16
 */
17
class StaticPageBuilder
18
{
19
    use InteractsWithDirectories;
20
21
    /**
22
     * Invoke the static page builder for the given page.
23
     */
24
    public static function handle(HydePage $page): string
25
    {
26
        $path = Hyde::sitePath($page->getOutputPath());
27
28
        static::needsParentDirectory($path);
29
30
        Hyde::shareViewData($page);
31
32
        Filesystem::putContents($path, $page->compile());
33
34
        return $path;
35
    }
36
}
37