diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-08-15 13:52:32 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-08-15 13:57:23 +0200 |
commit | 94575cc761c016b68135b398445d554bc984b1d5 (patch) | |
tree | 35f2decbb4cfed12e65f420228e5e1e150f36068 /vendor/plasmaconduit/path/src/PlasmaConduit | |
parent | 44733bc8b4f5f1a6fb26dea01b9d33c7b0321d67 (diff) |
swap out unlicensed lib
Diffstat (limited to 'vendor/plasmaconduit/path/src/PlasmaConduit')
-rw-r--r-- | vendor/plasmaconduit/path/src/PlasmaConduit/Path.php | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/vendor/plasmaconduit/path/src/PlasmaConduit/Path.php b/vendor/plasmaconduit/path/src/PlasmaConduit/Path.php deleted file mode 100644 index 0db583d7e..000000000 --- a/vendor/plasmaconduit/path/src/PlasmaConduit/Path.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -namespace PlasmaConduit; - -class Path { - - /** - * This function takes a variable amount of strings and joins - * them together so that they form a valid file path. - * - * @param {String ...} $peice - The peices of the file path - * @returns {String} - The final file path - */ - static public function join() { - $peices = array_filter(func_get_args(), function($value) { - return $value; - }); - return self::normalize(implode("/", $peices)); - } - - /** - * This function takes a valid file path and nomalizes it into - * the simplest form possible. - * - * @param {String} $path - The path to normalize - * @returns {String} - The normailized path - */ - static public function normalize($path) { - if (!strlen($path)) { - return "."; - } - - $isAbsolute = $path[0]; - $trailingSlash = $path[strlen($path) - 1]; - - $up = 0; - $peices = array_values(array_filter(explode("/", $path), function($n) { - return !!$n; - })); - for ($i = count($peices) - 1; $i >= 0; $i--) { - $last = $peices[$i]; - if ($last == ".") { - array_splice($peices, $i, 1); - } else if ($last == "..") { - array_splice($peices, $i, 1); - $up++; - } else if ($up) { - array_splice($peices, $i, 1); - $up--; - } - } - - $path = implode("/", $peices); - - if (!$path && !$isAbsolute) { - $path = "."; - } - - if ($path && $trailingSlash == "/") { - $path .= "/"; - } - - return ($isAbsolute == "/" ? "/" : "") . $path; - } - -}
\ No newline at end of file |