| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 26 | public static function getRelativePath($relativePath, $parentPath = '') |
||
| 27 | { |
||
| 28 | // Build full path to resource from given relative path |
||
| 29 | $fullPath = rtrim($parentPath, DIRECTORY_SEPARATOR) |
||
| 30 | .DIRECTORY_SEPARATOR |
||
| 31 | .ltrim($relativePath, DIRECTORY_SEPARATOR); |
||
| 32 | |||
| 33 | // Make real path with out possible "../" |
||
| 34 | $realPath = realpath($fullPath); |
||
| 35 | |||
| 36 | // Output link to static resource handler with relative path to project root |
||
| 37 | if ($realPath) { |
||
| 38 | return str_replace(dirname(getcwd()), '', $realPath); |
||
| 39 | } |
||
| 40 | |||
| 41 | throw new ResourceNotFound($fullPath); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |