Locator
in package
Class Locator.
The Locator class has methods for finding files and the class FQN using an Autoloader instance.
Table of Contents
- $autoloader : Autoloader
- __construct() : mixed
- Locator constructor.
- findFiles() : array<int, string>
- Find namesake files inside namespaced directories.
- getClassName() : string|null
- Gets the first Qualified Class Name in a given filename.
- getFiles() : array<int, string>
- Get a list of all files inside namespaced sub directories.
- getNamespacedFilepath() : string|null
- Get the first filepath found in all namespaces.
- listFiles() : array<int, string>|null
- Get a list of all files inside a directory.
- ensureExtension() : string
Properties
$autoloader
protected
Autoloader
$autoloader
Methods
__construct()
Locator constructor.
public
__construct(Autoloader $autoloader) : mixed
Parameters
- $autoloader : Autoloader
Return values
mixed —findFiles()
Find namesake files inside namespaced directories.
public
findFiles(string $filename[, string $extension = '.php' ]) : array<int, string>
Parameters
- $filename : string
-
The file name
- $extension : string = '.php'
-
The file extension
Return values
array<int, string> —An array of filenames found
getClassName()
Gets the first Qualified Class Name in a given filename.
public
getClassName(string $filename) : string|null
The "class name" can be the name of a class, an interface or a trait.
Parameters
- $filename : string
Tags
Return values
string|null —The class name or null if not found
getFiles()
Get a list of all files inside namespaced sub directories.
public
getFiles(string $subDirectory) : array<int, string>
Parameters
- $subDirectory : string
-
Sub directory path
Return values
array<int, string> —getNamespacedFilepath()
Get the first filepath found in all namespaces.
public
getNamespacedFilepath(string $file[, string $extension = '.php' ]) : string|null
Parameters
- $file : string
-
The file name without extension
- $extension : string = '.php'
-
The file extension
Return values
string|null —The filepath or null if not found
listFiles()
Get a list of all files inside a directory.
public
listFiles(string $directory) : array<int, string>|null
Parameters
- $directory : string
-
Absolute directory path
Return values
array<int, string>|null —Returns an array of filenames or null if the directory can not be resolved
ensureExtension()
protected
ensureExtension(string $filename, string $extension) : string
Parameters
- $filename : string
- $extension : string