SourceFile   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 3 1
A toArray() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Support\Filesystem;
6
7
use Hyde\Pages\Concerns\HydePage;
8
9
use function array_merge;
10
11
/**
12
 * File abstraction for a project source file.
13
 *
14
 * @see \Hyde\Foundation\Kernel\FileCollection
15
 */
16
class SourceFile extends ProjectFile
17
{
18
    /**
19
     * The associated page class string.
20
     *
21
     * @var class-string<\Hyde\Pages\Concerns\HydePage>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<\Hyde\Pages\Concerns\HydePage> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<\Hyde\Pages\Concerns\HydePage>.
Loading history...
22
     */
23
    public readonly string $pageClass;
24
25
    /** @param  class-string<\Hyde\Pages\Concerns\HydePage>  $pageClass */
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<\Hyde\Pages\Concerns\HydePage> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<\Hyde\Pages\Concerns\HydePage>.
Loading history...
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 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<\Hyde\Pages\Concerns\HydePage> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<\Hyde\Pages\Concerns\HydePage>.
Loading history...
32
    public function __construct(string $path, string $pageClass = HydePage::class)
33
    {
34
        parent::__construct($path);
35
        $this->pageClass = $pageClass;
0 ignored issues
show
Bug introduced by
The property pageClass is declared read-only in Hyde\Support\Filesystem\SourceFile.
Loading history...
36
    }
37
38
    public function toArray(): array
39
    {
40
        return array_merge(parent::toArray(), [
41
            'pageClass' => $this->pageClass,
42
        ]);
43
    }
44
}
45