From 965b1e70f8d519a22c051b82dfda7cc87d9207b6 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Wed, 15 Mar 2017 13:14:22 +0200 Subject: [PATCH] IHF: `relative_path` helper readme added. --- README.md | 23 +++++++++++++++++++ .../filesystem/RelativePathTest.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b77e03..ce47b22 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ Provides Laravel-specific and pure PHP helper functions. - [to_rfc2822_email](#to_rfc2822_email) - [to_swiftmailer_emails](#to_swiftmailer_emails) +- [Filesystem](#filesystem) + - [relative_path](#relative_path) + - [Format](#format) - [get_dump](#get_dump) - [format_bytes](#format_bytes) @@ -276,6 +279,26 @@ $address = to_swiftmailer_emails(['address' => 'john.doe@example.com', 'name' => // ["john.doe@example.com" => "John Doe"] ``` +## Filesystem + +#### `relative_path()` + +Returns the relative path of a directory given another one: + +```php +$path = relative_path('/var/www/htdocs', '/var/www/htdocs/example') + +// '../' +``` + +You can pass relative paths as a parameters: + +```php +$path = relative_path('/var/www/htdocs/example/public/../../', '/var/') + +// 'www/htdocs/' +``` + ## Format #### `get_dump()` diff --git a/tests/HelperFunctions/filesystem/RelativePathTest.php b/tests/HelperFunctions/filesystem/RelativePathTest.php index 739c10f..03a4b92 100644 --- a/tests/HelperFunctions/filesystem/RelativePathTest.php +++ b/tests/HelperFunctions/filesystem/RelativePathTest.php @@ -1,6 +1,6 @@