kiriyi / pathyi
简单的路径格式化工具。
1.0.1
2020-04-24 00:04 UTC
Requires
- php: ^7.4
This package is auto-updated.
Last update: 2024-09-24 09:47:04 UTC
README
这是一个简单的路径格式化工具。
安装
composer require kiryi/pathyi
用法
$pathyi = new \Kiryi\Pathyi\Formatter(); $path = $pathyi->format($path);
方法定义 format
format(string $path, bool $leadingSlash = false, bool $trailingSlash = false): string
参数
path
要格式化的路径。如果只有反斜杠出现,路径将返回带有前导/尾随反斜杠。如果不是,则使用正斜杠。
leadingSlash
定义返回的路径是否以斜杠开头(true)或不是(false,默认)。
trailingSlash
定义返回的路径是否以斜杠结尾(true)或不是(false,默认)。
返回值
返回格式化后的路径作为字符串。
示例
$path = '/this/is/my/path'; $pathyi = new \Kiryi\Pathyi\Formatter(); $path = $pathyi->format($path); // $path is now 'this/is/my/path' $path = $pathyi->format($path, true); // $path is now '/this/is/my/path' $path = $pathyi->format($path, false, true); // $path is now 'this/is/my/path/'