| Conditions | 7 |
| Paths | 6 |
| Total Lines | 29 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public static function diskPath($path) |
||
| 19 | { |
||
| 20 | // its full-based path? Lets return real path |
||
| 21 | if (Str::startsWith(root, $path)) { |
||
|
|
|||
| 22 | // fix path collisions if is not exist |
||
| 23 | if (file_exists($path)) { |
||
| 24 | return realpath($path); |
||
| 25 | } else { |
||
| 26 | return $path; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | // else - sounds like relative path |
||
| 30 | $path = Str::replace('\\', '/', $path); |
||
| 31 | $splitPath = explode('/', $path); |
||
| 32 | |||
| 33 | $outputPath = []; |
||
| 34 | foreach ($splitPath as $index => $part) { |
||
| 35 | if ($part === '.' || Str::length(trim($part)) < 1) { |
||
| 36 | continue; |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($part === '..') { // level-up (: |
||
| 40 | array_pop($outputPath); |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | $outputPath[] = trim($part); |
||
| 45 | } |
||
| 46 | return implode(DIRECTORY_SEPARATOR, $outputPath); |
||
| 47 | } |
||
| 63 |