\Phabstractic\Data\Components\ResourcePathInterface

Path Interface - Defines A Path Structure

A path consists of a directory, a file, and a file extension. This class keeps track of the directory path, and the assigned or acceptable extensions allowed by the path. It offers a function to test if a file is found in the path given the allowed extensions

CHANGELOG

1.0: Created PathInterface - August 3rd, 2016

Summary

Methods
Constants
getIdentifier()
isRelative()
getPath()
setPath()
addExtension()
getExtensions()
removeExtension()
isExtension()
isFilename()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

getIdentifier()

getIdentifier() : string

Get this particular path's identifier

Returns

string —

The universally unique vertex identifier

isRelative()

isRelative() : boolean

Is this path relative?

Returns

boolean

getPath()

getPath() : string

Retrieve the current path

Path can be relative or absolute

Returns

string —

The path in the instance

setPath()

setPath(  $path) : \Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Path

Assign the path

NOTE: This should be a directory, NOT a file

If option Check has been specified we see if the directory actually exists.

Parameters

$path

Throws

\Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Exception\DomainException

Path does not exist (only thrown if Check option is set)

Returns

\Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Path —

$this for chaining

addExtension()

addExtension(  $extensions) : \Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Path

Add an allowed extension

This puts a extension or array of extensions into the list of allowed and looked for extensions when a filename is supplied to the path.

NOTE: Extensions preceding periods (the first only) are removed. '.some.extension' becomes 'some.extension'

Parameters

$extensions

Returns

\Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Path —

$this for chaining

getExtensions()

getExtensions() : array

Retrieve the list of allowed extensions

Returns

array —

A simple array of allowed extensions

removeExtension()

removeExtension(  $extension) : mixed

Remove a particular extension from the set of allowed extensions

Parameters

$extension

Returns

mixed —

Whatever the remove method in Types\Set returns

isExtension()

isExtension(  $extension) : boolean

Is an extension allowed?

Parameters

$extension

Returns

boolean

isFilename()

isFilename(  $filename,   $basePath = '',   $reqExtension = '') : string|null

Find a particular filename in the path

This method returns a filename (or '' on failure) when a given filename is found in the path with an acceptable extension.

NOTE: Do not pass the required extension in $filename Use $reqExtension instead.

Parameters

$filename
$basePath
$reqExtension

Throws

\Phabstractic\Data\Components\Resource\Phabstractic\Data\Components\Exception\DomainException

Returns

string|null —

The full path with extension, or null on failure