-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © 2024 cclilshy | ||
* Email: jingnigg@gmail.com | ||
* | ||
* This software is licensed under the MIT License. | ||
* For full license details, please visit: https://opensource.org/licenses/MIT | ||
* | ||
* By using this software, you agree to the terms of the license. | ||
* Contributions, suggestions, and feedback are always welcome! | ||
*/ | ||
|
||
namespace Laravel\Ripple; | ||
|
||
use Throwable; | ||
|
||
use function realpath; | ||
use function rtrim; | ||
use function str_starts_with; | ||
use function strlen; | ||
use function substr; | ||
|
||
use const DIRECTORY_SEPARATOR; | ||
|
||
class Util | ||
{ | ||
/** | ||
* @param $path1 | ||
* @param $path2 | ||
* | ||
* @return string | ||
*/ | ||
public static function getRelativePath($path1, $path2): string | ||
{ | ||
try { | ||
$path1 = rtrim(realpath($path1), DIRECTORY_SEPARATOR); | ||
$path2 = rtrim(realpath($path2), DIRECTORY_SEPARATOR); | ||
|
||
if (!$path1 || !$path2) { | ||
return ''; | ||
} | ||
|
||
if (str_starts_with($path1, $path2)) { | ||
return substr($path1, strlen($path2) + 1); | ||
} | ||
} catch (Throwable $e) { | ||
return ''; | ||
} | ||
|
||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters