Conditions | 7 |
Paths | 7 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | public static function resolveAsset(AssetBundle $bundle, string $pathAsset, array $assetMap): ?string |
||
32 | { |
||
33 | if (isset($assetMap[$pathAsset])) { |
||
34 | return $assetMap[$pathAsset]; |
||
35 | } |
||
36 | |||
37 | if (!empty($bundle->sourcePath) && static::isRelative($pathAsset)) { |
||
38 | $pathAsset = $bundle->sourcePath . '/' . $pathAsset; |
||
39 | } |
||
40 | |||
41 | $n = mb_strlen($pathAsset, 'utf-8'); |
||
42 | |||
43 | foreach ($assetMap as $from => $to) { |
||
44 | $n2 = mb_strlen($from, 'utf-8'); |
||
45 | if ($n2 <= $n && substr_compare($pathAsset, $from, $n - $n2, $n2) === 0) { |
||
46 | return $to; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | return null; |
||
51 | } |
||
53 |