<?php namespace Lightscale\LaralightAssets; use Illuminate\Support\Str; use Illuminate\Support\Collection; class FileString { public ?string $manifestName = null; public string $fileUri; public function __construct(string $file) { $escape = '\\'; $seperator = '::'; $seperatorLen = strlen($seperator); $pos = 0; while( $pos !== false ) { $pos = strpos($file, $seperator, $pos); if ($pos > 0 && $file[$pos - 1] === $escape) { $pos += $seperatorLen; } else break; } $unescape = fn($v) => str_replace($escape . $seperator, $seperator, $v); if ($pos === false) { $this->fileUri = $unescape($file); } else { $this->manifestName = $unescape(substr($file, 0, $pos)); $this->fileUri = $unescape(substr($file, $pos + $seperatorLen)); } } }