Documentation

Util
in package

Convenient utility functions that don't neatly fit anywhere else.

Table of Contents

finder()  : Finder
Build a Symfony Finder object that scans the given $directory.
getRelativePath()  : string
Turns the given $fullPath into a relative path based on $basePaths, which can either be a single string path, or a list of possible paths. If a list is given, the first matching basePath in the list will be used to compute the relative path. If no relative path could be computed, the original string will be returned because there is always a chance it was a valid relative path to begin with.
refDecode()  : string
Converted the escaped characters "~1" and "~" back to "/" and "~".
refEncode()  : string
Escapes the special characters "/" and "~".
shorten()  : string|array<string|int, string>
Shorten class name(s).
removePrefix()  : string|null
Removes a prefix from the start of a string if it exists, or null otherwise.

Methods

finder()

Build a Symfony Finder object that scans the given $directory.

public static finder(array<string|int, mixed>|Finder|string $directory[, null|array<string|int, mixed>|string $exclude = null ][, null|string $pattern = null ]) : Finder
Parameters
$directory : array<string|int, mixed>|Finder|string

The directory(s) or filename(s)

$exclude : null|array<string|int, mixed>|string = null

The directory(s) or filename(s) to exclude (as absolute or relative paths)

$pattern : null|string = null

The pattern of the files to scan

Tags
throws
InvalidArgumentException
Return values
Finder

getRelativePath()

Turns the given $fullPath into a relative path based on $basePaths, which can either be a single string path, or a list of possible paths. If a list is given, the first matching basePath in the list will be used to compute the relative path. If no relative path could be computed, the original string will be returned because there is always a chance it was a valid relative path to begin with.

public static getRelativePath(string $fullPath, array<string|int, mixed>|string $basePaths) : string

It should be noted that these are "relative paths" primarily in Finder's sense of them, and conform specifically to what is expected by functions like exclude() and notPath(). In particular, leading and trailing slashes are removed.

Parameters
$fullPath : string
$basePaths : array<string|int, mixed>|string
Return values
string

refDecode()

Converted the escaped characters "~1" and "~" back to "/" and "~".

public static refDecode(string $encoded) : string

https://swagger.io/docs/specification/using-ref/ https://tools.ietf.org/html/rfc6901#page-3

Parameters
$encoded : string
Return values
string

refEncode()

Escapes the special characters "/" and "~".

public static refEncode(string $raw) : string

https://swagger.io/docs/specification/using-ref/ https://tools.ietf.org/html/rfc6901#page-3

Parameters
$raw : string
Return values
string

shorten()

Shorten class name(s).

public static shorten(array<string|int, mixed>|object|string $classes) : string|array<string|int, string>
Parameters
$classes : array<string|int, mixed>|object|string

Class(es) to shorten

Return values
string|array<string|int, string>

One or more shortened class names

removePrefix()

Removes a prefix from the start of a string if it exists, or null otherwise.

private static removePrefix(string $str, string $prefix) : string|null
Parameters
$str : string
$prefix : string
Return values
string|null

Search results