Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
StaticPageBuilder
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 handle
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Hyde\Framework\Actions;
6
7use Hyde\Hyde;
8use Hyde\Facades\Filesystem;
9use Hyde\Framework\Concerns\InteractsWithDirectories;
10use Hyde\Pages\Concerns\HydePage;
11
12/**
13 * Converts a Hyde page object into a static HTML page.
14 */
15class StaticPageBuilder
16{
17    use InteractsWithDirectories;
18
19    /**
20     * Invoke the static page builder for the given page.
21     */
22    public static function handle(HydePage $page): string
23    {
24        $path = Hyde::sitePath($page->getOutputPath());
25
26        static::needsParentDirectory($path);
27
28        Hyde::shareViewData($page);
29
30        Filesystem::putContents($path, $page->compile());
31
32        return $path;
33    }
34}