Passed
Push — master ( a9db05...32ab90 )
by Caen
03:20 queued 13s
created

DiscoveryService::getMediaAssetFiles()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework\Services;
6
7
use Hyde\Hyde;
8
use Illuminate\Support\Str;
9
use function unslash;
10
11
/**
12
 * General Discovery Helpers for HydePHP Auto-Discovery.
13
 *
14
 * Offloads FoundationCollection logic and provides helpers for common code.
15
 *
16
 * @see \Hyde\Framework\Testing\Feature\DiscoveryServiceTest
17
 */
18
class DiscoveryService
19
{
20
    /**
21
     * Format a filename to an identifier for a given model. Unlike the basename function, any nested paths
22
     * within the source directory are retained in order to satisfy the page identifier definition.
23
     *
24
     * @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...
25
     * @param  string  $filepath  Example: index.blade.php
26
     * @return string Example: index
27
     */
28
    public static function pathToIdentifier(string $pageClass, string $filepath): string
29
    {
30
        return unslash(Str::between(Hyde::pathToRelative($filepath),
31
            $pageClass::sourceDirectory().'/',
32
            $pageClass::fileExtension())
33
        );
34
    }
35
}
36