xenolope/namespacery

A library to help parse namespaces

v0.6 2014-10-26 13:52 UTC

This package is auto-updated.

Last update: 2024-04-07 14:35:16 UTC


README

Build Status

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.