Helpers
final class Helpers
Asset utility functions.
Constants
| private ExtensionToMime |
|
Methods
Creates an Asset of the appropriate type for the given URL.
Guesses the MIME type from the file extension in the given URL or path, or null if unknown.
Splits a potentially qualified reference 'mapper:reference' into a [mapper, reference] array.
Validates an array of options against allowed optional and required keys.
Estimates the duration (in seconds) of an MP3 file, assuming constant bitrate (CBR).
Reads the Vite dev server URL from the given info file, or returns null if unavailable.
Details
at line 32
static Asset
createAssetFromUrl(string $url, string|null $path = null, array $args = [])
Creates an Asset of the appropriate type for the given URL.
The type is determined from the 'mimeType' key in $args if provided, otherwise guessed from the file extension of $path or $url.
at line 54
static string|null
guessMimeTypeFromExtension(string $url)
Guesses the MIME type from the file extension in the given URL or path, or null if unknown.
at line 66
static array
parseReference(string $qualifiedRef)
Splits a potentially qualified reference 'mapper:reference' into a [mapper, reference] array.
at line 82
static void
checkOptions(array $array, array $optional = [], array $required = [])
Validates an array of options against allowed optional and required keys.
at line 97
static float
guessMP3Duration(string $path)
Estimates the duration (in seconds) of an MP3 file, assuming constant bitrate (CBR).
at line 130
static string|null
detectDevServer(string $infoFile)
Reads the Vite dev server URL from the given info file, or returns null if unavailable.