blob: 0bdca097583d737f07def0369c907e44ff2bd454 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<?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));
}
}
}
|