\Charcoal\App\ScriptPathScriptTrait

Path-handling utilities

Requirements:

  • DIRECTORY_SEPARATORS class constant.
  • DEFAULT_BASENAME class constant.
  • self::parseAsArray()

Summary

Methods
Properties
Constants
basePath()
processMultiplePaths()
pathExists()
filterPath()
filterWritablePath()
globRecursive()
No public properties found
No constants found
No protected methods found
$globCache
N/A
No private methods found
No private properties found
N/A

Properties

$globCache

$globCache : array

The cache of globbed paths.

Type

array

Methods

basePath()

basePath() : string|null

Retrieve the base path.

Returns

string|null

processMultiplePaths()

processMultiplePaths(string|array<mixed,string>  $paths) : array<mixed,string>

Process multiple paths.

Parameters

string|array<mixed,string> $paths

One or many paths to scan.

Throws

\InvalidArgumentException

If the paths are invalid.

Returns

array<mixed,string>

pathExists()

pathExists(string  $path) : boolean

Determine if the path exists.

Parameters

string $path

Path to the file or directory.

Throws

\InvalidArgumentException

If the path is invalid.

Returns

boolean —

Returns TRUE if the path exists.

filterPath()

filterPath(string  $path, string|null  $trim = null) : string

Filter the given path.

Trims leading and trailing directory paths

Parameters

string $path

Path to the file or directory.

string|null $trim

The characters to strip from the $path.

Throws

\InvalidArgumentException

If the path is invalid.

Returns

string —

Returns the filtered path.

filterWritablePath()

filterWritablePath(string  $path, string|null  $name = null) : string

Filter the given path to be writable.

Parameters

string $path

A writable path to a file or directory.

string|null $name

The target file name.

Throws

\InvalidArgumentException

If the path is invalid.

Returns

string —

Returns the filtered path.

globRecursive()

globRecursive(string  $pattern, integer  $flags) : array

Recursively find pathnames matching a pattern.

Parameters

string $pattern

The search pattern.

integer $flags

Bitmask of {@see glob()} options.

Returns

array