for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Hyde\Framework\Services;
use Hyde\Hyde;
use Illuminate\Support\Str;
use function unslash;
/**
* General Discovery Helpers for HydePHP Auto-Discovery.
*
* Offloads FoundationCollection logic and provides helpers for common code.
* @see \Hyde\Framework\Testing\Feature\DiscoveryServiceTest
*/
class DiscoveryService
{
* Format a filename to an identifier for a given model. Unlike the basename function, any nested paths
* within the source directory are retained in order to satisfy the page identifier definition.
* @param class-string<\Hyde\Pages\Concerns\HydePage> $pageClass
class-string<\Hyde\Pages\Concerns\HydePage>
0
* @param string $filepath Example: index.blade.php
* @return string Example: index
public static function pathToIdentifier(string $pageClass, string $filepath): string
return unslash(Str::between(Hyde::pathToRelative($filepath),
$pageClass::sourceDirectory().'/',
$pageClass::fileExtension())
);
}