final class Helpers

Static helper class providing utility functions for working with assets.

Constants

private ExtensionToMime

Methods

static Asset
createAssetFromUrl(string $url, string|null $path = null, array $args = [])

Creates an Asset instance. The asset type is detected by 'mimeType' if provided in $args, otherwise is guessed from the file extension of $path or $url.

static string|null
guessMimeTypeFromExtension(string $url)

No description

static array
parseReference(string $qualifiedRef)

Splits a potentially qualified reference 'mapper:reference' into a [mapper, reference] array.

static void
checkOptions(array $array, array $optional = [], array $required = [])

Validates an array of options against allowed optional and required keys.

static float
guessMP3Duration(string $path)

Estimates the duration (in seconds) of an MP3 file, assuming constant bitrate (CBR).

static string|null
detectDevServer(string $infoFile)

No description

Details

at line 33
static Asset createAssetFromUrl(string $url, string|null $path = null, array $args = [])

Creates an Asset instance. The asset type is detected by 'mimeType' if provided in $args, otherwise is guessed from the file extension of $path or $url.

Parameters

string $url
string|null $path
array $args

parameters passed to the asset constructor

Return Value

Asset

at line 52
static string|null guessMimeTypeFromExtension(string $url)

No description

Parameters

string $url

Return Value

string|null

at line 64
static array parseReference(string $qualifiedRef)

Splits a potentially qualified reference 'mapper:reference' into a [mapper, reference] array.

Parameters

string $qualifiedRef

Return Value

array

at line 77
static void checkOptions(array $array, array $optional = [], array $required = [])

Validates an array of options against allowed optional and required keys.

Parameters

array $array
array $optional
array $required

Return Value

void

Exceptions

InvalidArgumentException

at line 92
static float guessMP3Duration(string $path)

Estimates the duration (in seconds) of an MP3 file, assuming constant bitrate (CBR).

Parameters

string $path

Return Value

float

Exceptions

RuntimeException

at line 118
static string|null detectDevServer(string $infoFile)

No description

Parameters

string $infoFile

Return Value

string|null

Traits

StaticClass