Documentation

SegmentedPathInterface extends Countable, IteratorAggregate, PathInterface
in

Tags
extends

Table of Contents

Methods

__toString()  : string
Returns the instance string representation.
append()  : self
Appends a segment to the path.
count()  : int
Returns the total number of segments in the path.
decoded()  : string
Returns the decoded path.
get()  : string|null
Retrieves a single path segment.
getBasename()  : string
Returns the path basename.
getDirname()  : string
Returns parent directory's path.
getExtension()  : string
Returns the basename extension.
getIterator()  : Iterator<string|int, string>
Iterate over the path segment.
getUriComponent()  : string
Returns the instance string representation with its optional URI delimiters.
hasTrailingSlash()  : bool
Tells whether the path has a trailing slash.
isAbsolute()  : bool
Tells whether the path is absolute or relative.
jsonSerialize()  : string|null
Returns the instance json representation.
keys()  : array<string|int, int>
Returns the associated key for a specific segment.
prepend()  : self
Prepends a segment to the path.
slice()  : self
Extracts a slice of $length elements starting at position $offset from the host.
toString()  : string
Returns the instance string representation.
value()  : string|null
Returns the instance string representation.
withBasename()  : self
Returns an instance with the specified basename.
withDirname()  : self
Returns an instance with the specified parent directory's path.
withExtension()  : self
Returns an instance with the specified basename extension.
withLeadingSlash()  : self
Returns an instance with a leading slash.
withoutDotSegments()  : self
Returns an instance without dot segments.
withoutEmptySegments()  : self
Returns an instance without duplicate delimiters.
withoutLeadingSlash()  : self
Returns an instance without a leading slash.
withoutSegment()  : self
Returns an instance without the specified segment.
withoutTrailingSlash()  : self
Returns an instance without a trailing slash.
withSegment()  : self
Returns an instance with the modified segment.
withTrailingSlash()  : self
Returns an instance with a trailing slash.

Methods

__toString()

Returns the instance string representation.

public __toString() : string

If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.

If the instance is not defined, an empty string is returned

Return values
string

count()

Returns the total number of segments in the path.

public count() : int
Return values
int

decoded()

Returns the decoded path.

public decoded() : string
Return values
string

get()

Retrieves a single path segment.

public get(int $offset) : string|null

If the segment offset has not been set, returns null.

Parameters
$offset : int
Return values
string|null

getExtension()

Returns the basename extension.

public getExtension() : string
Return values
string

getIterator()

Iterate over the path segment.

public getIterator() : Iterator<string|int, string>
Return values
Iterator<string|int, string>

getUriComponent()

Returns the instance string representation with its optional URI delimiters.

public getUriComponent() : string

The value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.

If the instance is not defined, an empty string is returned

Return values
string

hasTrailingSlash()

Tells whether the path has a trailing slash.

public hasTrailingSlash() : bool
Return values
bool

isAbsolute()

Tells whether the path is absolute or relative.

public isAbsolute() : bool
Return values
bool

jsonSerialize()

Returns the instance json representation.

public jsonSerialize() : string|null

If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986 or RFC 1738.

If the instance is not defined, null is returned

Return values
string|null

keys()

Returns the associated key for a specific segment.

public keys([Stringable|string|null $segment = null ]) : array<string|int, int>

If a value is specified only the keys associated with the given value will be returned

Parameters
$segment : Stringable|string|null = null
Return values
array<string|int, int>

slice()

Extracts a slice of $length elements starting at position $offset from the host.

public slice(int $offset[, int|null $length = null ]) : self

This method MUST retain the state of the current instance, and return an instance that contains the selected slice.

If $length is null it returns all elements from $offset to the end of the Path.

Parameters
$offset : int
$length : int|null = null
Return values
self

toString()

Returns the instance string representation.

public toString() : string

If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.

If the instance is not defined, an empty string is returned

Return values
string

value()

Returns the instance string representation.

public value() : string|null

If the instance is defined, the value returned MUST be percent-encoded, but MUST NOT double-encode any characters. To determine what characters to encode, please refer to RFC 3986, Sections 2 and 3.

If the instance is not defined null is returned

Return values
string|null

withBasename()

Returns an instance with the specified basename.

public withBasename(Stringable|string $basename) : self

This method MUST retain the state of the current instance, and return an instance that contains the extension basename modified.

Parameters
$basename : Stringable|string
Return values
self

withDirname()

Returns an instance with the specified parent directory's path.

public withDirname(Stringable|string $path) : self

This method MUST retain the state of the current instance, and return an instance that contains the extension basename modified.

Parameters
$path : Stringable|string
Return values
self

withExtension()

Returns an instance with the specified basename extension.

public withExtension(Stringable|string $extension) : self

This method MUST retain the state of the current instance, and return an instance that contains the extension basename modified.

Parameters
$extension : Stringable|string
Return values
self

withLeadingSlash()

Returns an instance with a leading slash.

public withLeadingSlash() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component with a leading slash

Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withoutDotSegments()

Returns an instance without dot segments.

public withoutDotSegments() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component normalized by removing the dot segment.

Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withoutEmptySegments()

Returns an instance without duplicate delimiters.

public withoutEmptySegments() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component normalized by removing multiple consecutive empty segment

Return values
self

withoutLeadingSlash()

Returns an instance without a leading slash.

public withoutLeadingSlash() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component without a leading slash

Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withoutSegment()

Returns an instance without the specified segment.

public withoutSegment(int ...$keys) : self

This method MUST retain the state of the current instance, and return an instance that contains the modified component

If $key is non-negative, the removed segment will be the segment at $key position from the start. If $key is negative, the removed segment will be the segment at $key position from the end.

Parameters
$keys : int
Tags
throws
SyntaxError

If the key is invalid

Return values
self

withoutTrailingSlash()

Returns an instance without a trailing slash.

public withoutTrailingSlash() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component without a trailing slash

Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

withSegment()

Returns an instance with the modified segment.

public withSegment(int $key, Stringable|string $segment) : self

This method MUST retain the state of the current instance, and return an instance that contains the new segment

If $key is non-negative, the added segment will be the segment at $key position from the start. If $key is negative, the added segment will be the segment at $key position from the end.

Parameters
$key : int
$segment : Stringable|string
Tags
throws
SyntaxError

If the key is invalid

Return values
self

withTrailingSlash()

Returns an instance with a trailing slash.

public withTrailingSlash() : self

This method MUST retain the state of the current instance, and return an instance that contains the path component with a trailing slash

Tags
throws
SyntaxError

for invalid component or transformations that would result in a object in invalid state.

Return values
self

        
On this page

Search results