| 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 |
||
| 31 | 23 | public static function resolveAsset(AssetBundle $bundle, string $pathAsset, array $assetMap): ?string |
|
| 32 | { |
||
| 33 | 23 | if (isset($assetMap[$pathAsset])) { |
|
| 34 | 1 | return $assetMap[$pathAsset]; |
|
| 35 | } |
||
| 36 | |||
| 37 | 22 | if (!empty($bundle->sourcePath) && static::isRelative($pathAsset)) { |
|
| 38 | 6 | $pathAsset = $bundle->sourcePath . '/' . $pathAsset; |
|
| 39 | } |
||
| 40 | |||
| 41 | 22 | $n = mb_strlen($pathAsset, 'utf-8'); |
|
| 42 | |||
| 43 | 22 | 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 | 22 | return null; |
|
| 51 | } |
||
| 53 |