xenolope / namespacery
A library to help parse namespaces
v0.6
2014-10-26 13:52 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-12-07 16:21:10 UTC
README
Namespacery is a simple PHP library to help parse namespaces in an easily-accessible way.
Installation
The library can be installed with Composer, by including the following in your composer.json
:
{ "require": { "xenolope/namespacery": "0.*" } }
Usage
$resolver = new \Xenolope\Namespacery('Vendor\Package\Group\Class'); // Returns the value of the first namespace segment $resolver->parseSegments()->getFirstSegment(); // Returns the value of the last namespace segment $resolver->parseSegments()->getLastSegment(); // Returns the value of the segment at the given index, or an \OutOfBoundsException if the index doesn't exist $resolver->parseSegments()->getSegment(1); // Returns an array of all segments in the namespace $resolver->parseSegments()->getSegments();
License
Namespacery is released under the MIT License; please see LICENSE for more information.