Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
SourceFile
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 make
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Hyde\Support\Filesystem;
6
7use Hyde\Pages\Concerns\HydePage;
8
9use function array_merge;
10
11/**
12 * File abstraction for a project source file.
13 *
14 * @see \Hyde\Foundation\Kernel\FileCollection
15 */
16class SourceFile extends ProjectFile
17{
18    /**
19     * The associated page class string.
20     *
21     * @var class-string<\Hyde\Pages\Concerns\HydePage>
22     */
23    public readonly string $pageClass;
24
25    /** @param  class-string<\Hyde\Pages\Concerns\HydePage>  $pageClass */
26    public static function make(string $path, string $pageClass = HydePage::class): static
27    {
28        return new static($path, $pageClass);
29    }
30
31    /** @param  class-string<\Hyde\Pages\Concerns\HydePage>  $pageClass */
32    public function __construct(string $path, string $pageClass = HydePage::class)
33    {
34        parent::__construct($path);
35        $this->pageClass = $pageClass;
36    }
37
38    public function toArray(): array
39    {
40        return array_merge(parent::toArray(), [
41            'pageClass' => $this->pageClass,
42        ]);
43    }
44}