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

StaticPageBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 17
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 17
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 1
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