77
88
99/**
10- * Static helper class providing utility functions for working with assets .
10+ * Asset utility functions.
1111 */
1212final class Helpers
1313{
@@ -24,9 +24,10 @@ final class Helpers
2424
2525
2626 /**
27- * Creates an Asset instance. The asset type is detected by 'mimeType' if provided in $args,
28- * otherwise is guessed from the file extension of $path or $url.
29- * @param array<string, mixed> $args parameters passed to the asset constructor
27+ * Creates an Asset of the appropriate type for the given URL.
28+ * The type is determined from the 'mimeType' key in $args if provided,
29+ * otherwise guessed from the file extension of $path or $url.
30+ * @param array<string, mixed> $args additional constructor arguments for the asset
3031 */
3132 public static function createAssetFromUrl (string $ url , ?string $ path = null , array $ args = []): Asset
3233 {
@@ -47,6 +48,9 @@ public static function createAssetFromUrl(string $url, ?string $path = null, arr
4748 }
4849
4950
51+ /**
52+ * Guesses the MIME type from the file extension in the given URL or path, or null if unknown.
53+ */
5054 public static function guessMimeTypeFromExtension (string $ url ): ?string
5155 {
5256 return preg_match ('~\.([a-z0-9]{1,5})([?#]|$)~i ' , $ url , $ m )
@@ -120,6 +124,9 @@ public static function guessMP3Duration(string $path): float
120124 }
121125
122126
127+ /**
128+ * Reads the Vite dev server URL from the given info file, or returns null if unavailable.
129+ */
123130 public static function detectDevServer (string $ infoFile ): ?string
124131 {
125132 return ($ info = @file_get_contents ($ infoFile )) // @ file may not exists
0 commit comments