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