Download the PHP package jstewmc/path without Composer
On this page you can find all versions of the php package jstewmc/path. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package path
Path
A class for dealing with string paths in PHP.
A path is a route through a hierarchy, for example, a folder in a file system or a category in a department tree.
Feel free to check out the API documentation, report an issue, contribute, or ask a question.
Segments
A path is composed of segments. Each segment represents a step in the path. For example, the path foo/bar/baz
has three segments: foo
, bar
, and baz
.
Segments are indexed starting with 0. So, in the path foo/bar/baz
, the index of foo
is 0. The index of bar
is 1, and the index of baz
is 2.
Most methods that use a segment's index as an argument will accept an offset. An offset can be positive (that many places from the beginning of the path) or negative (that many places from the end of the path). For example, an offset of 1
is the second segment in the path, and an offset of -1
is the last segment in the path. In addition, most methods accept the special strings first
and last
.
You can append, prepend, insert, set, and unset a path's segments:
The example above uses separate method calls. However, you can chain most of the methods:
Whenever a Path is used as a string, it will, no surprise, return the path as a string:
You can get, find, and verify a segment by it's value or offset:
Path
You can also slice and reverse a path.
You can slice and reverse the current path:
Or, you can slice and reverse a clone:
Tests
Tests cover more than 90% of the code. I'm not exactly sure what's missing, because I'm pretty sure I wrote tests for everything. If you see something missing, let me know.
Contributing
Feel free to contribute your own improvements:
- Fork
- Clone
- PHPUnit
- Branch
- PHPUnit
- Code
- PHPUnit
- Commit
- Push
- Pull request
- Relax and eat a Paleo muffin
See CONTRIBUTING.md for details.
Author
Jack Clayton - [email protected].
License
Url is released under the MIT License. See the LICENSE file for details.
History
You can view the (short) history of the Url project in the CHANGELOG.md file.