summaryrefslogtreecommitdiffstats
path: root/vendor/riimu/kit-pathjoin/examples/example.php
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-08-15 13:52:32 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2015-08-15 13:57:23 +0200
commit94575cc761c016b68135b398445d554bc984b1d5 (patch)
tree35f2decbb4cfed12e65f420228e5e1e150f36068 /vendor/riimu/kit-pathjoin/examples/example.php
parent44733bc8b4f5f1a6fb26dea01b9d33c7b0321d67 (diff)
swap out unlicensed lib
Diffstat (limited to 'vendor/riimu/kit-pathjoin/examples/example.php')
-rw-r--r--vendor/riimu/kit-pathjoin/examples/example.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/vendor/riimu/kit-pathjoin/examples/example.php b/vendor/riimu/kit-pathjoin/examples/example.php
new file mode 100644
index 000000000..81d64a025
--- /dev/null
+++ b/vendor/riimu/kit-pathjoin/examples/example.php
@@ -0,0 +1,34 @@
+<?php
+
+require '../src/autoload.php';
+use Riimu\Kit\PathJoin\Path;
+
+// Both of the following will output 'foo/bar' on Unix and 'foo\bar' on Windows
+echo Path::normalize('foo/bar') . PHP_EOL;
+echo Path::join('foo', 'bar') . PHP_EOL;
+
+// The join method accepts multiple arguments or a single array
+echo Path::join('foo', 'bar', 'baz') . PHP_EOL; // outputs 'foo/bar/baz'
+echo Path::join(['foo', 'bar', 'baz']) . PHP_EOL; // outputs 'foo/bar/baz'
+
+// The '.' and '..' directory references will be resolved in the paths
+echo Path::normalize('foo/./bar/../baz') . PHP_EOL; // outputs 'foo/baz'
+echo Path::join(['foo/./', 'bar', '../baz']) . PHP_EOL; // outputs 'foo/baz'
+
+// Only the first path can denote an absolute path in the join method
+echo Path::join('/foo', '/bar/baz') . PHP_EOL; // outputs '/foo/bar/baz'
+echo Path::join('foo', '/bar') . PHP_EOL; // outputs 'foo/bar'
+echo Path::join('foo', '../bar', 'baz') . PHP_EOL; // outputs 'bar/baz'
+echo Path::join('', '/bar', 'baz') . PHP_EOL; // outputs 'bar/baz'
+
+// Relative paths can start with a '..', but absolute paths cannot
+echo Path::join('/foo', '../../bar', 'baz') . PHP_EOL; // outputs '/bar/baz'
+echo Path::join('foo', '../../bar', 'baz') . PHP_EOL; // outputs '../bar/baz'
+
+// Empty path will result in a '.'
+echo Path::normalize('foo/..') . PHP_EOL;
+echo Path::join('foo', 'bar', '../..') . PHP_EOL;
+
+echo Path::normalize('/foo/bar') . PHP_EOL; // outputs 'C:\foo\Bar'
+echo Path::normalize('D:/foo/bar') . PHP_EOL; // outputs 'D:\foo\Bar'
+echo Path::normalize('/foo/bar', false) . PHP_EOL; // outputs '\foo\Bar'