crell/path
最新稳定版本:0.1.2
Composer 安装命令:
composer require crell/path
包简介
Data model value objects for handling paths.
README 文档
README
Crell/Path is a simple library that provides typed value objects for handling paths. Paths may be either a PathFragment (no leading /) or an AbsolutePath. An AbsolutePath always begins either with a / or a stream identifier.
The contents of an absolute path may also be retrieved, if there is an actual file that it points to.
A Path object's primary purpose is to centralize and abstract away the various and sundry complexities and edge cases of manipulating paths: Getting a parent path (have to handle the case where there isn't one, with or without a stream), Concatenating two paths (have to handle the leading/trailing slashes, accounting for when one path or the other is the root path), filtering out and rejecting suspicious paths that contain .., and so on.
use Crell\Path\Path; // Creates a Path Fragment $frag = Path::create('foo/bar'); // Creates an Absolute Path $abs = Path::create('/baz/beep'); $new = $abs->concat($frag); // Prints /baz/beep/foo/bar print $new; // Prints /baz/beep/foo print $new->parent(); $file = '/narf.jpg'; $fileAbs = $abs->concat($file); // Prints /baz/beep/narf.jpg print $fileAbs;
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
Credits
License
The Lesser GPL version 3 or later. Please see License File for more information.
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2025-05-05