Passed
Push — master ( 85961b...721b09 )
by Caen
03:14 queued 13s
created

SourceFile::withoutDirectoryPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Support\Filesystem;
6
7
use Hyde\Pages\Concerns\HydePage;
8
9
/**
10
 * File abstraction for a project source file.
11
 *
12
 * @see \Hyde\Foundation\Kernel\FileCollection
13
 */
14
class SourceFile extends ProjectFile
15
{
16
    /**
17
     * The associated page class string.
18
     *
19
     * @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...
20
     */
21
    public readonly string $pageClass;
22
23
    /** @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...
24
    public static function make(string $path, string $pageClass = HydePage::class): static
25
    {
26
        return new static($path, $pageClass);
27
    }
28
29
    /** @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...
30
    public function __construct(string $path, string $pageClass = HydePage::class)
31
    {
32
        parent::__construct($path);
33
        $this->pageClass = $pageClass;
0 ignored issues
show
Bug introduced by
The property pageClass is declared read-only in Hyde\Support\Filesystem\SourceFile.
Loading history...
34
    }
35
36
    public function toArray(): array
37
    {
38
        return array_merge(parent::toArray(), [
39
            'pageClass' => $this->pageClass,
40
        ]);
41
    }
42
}
43