ClassFinder
in package
* Represents a finder for classes that there are in a specified directory and a specific namespace.
Table of Contents
- getClassesInNamespace() : array<string|int, mixed>
- Search all classes defined in the namespace using autoloading based in psr-4 standard, only serach in the directory and a level for subdirectories.
- getClassName() : string
- Return correct class name using the namespace.
- getDefinedNamespaces() : array<string|int, mixed>
- Return the standard autoload psr-4 definition in composer.json.
- getNamespaceDirectory() : string
- Returns the namespace directory if it exists or false otherwise.
- listAllFiles() : array<string|int, mixed>
- A simple recursive function to list all files and subdirectories in a directory.
Methods
getClassesInNamespace()
Search all classes defined in the namespace using autoloading based in psr-4 standard, only serach in the directory and a level for subdirectories.
public
static getClassesInNamespace(string $composerDir, string $namespace[, string $autoloaderSection = 'autoload' ][, string $psr = 'psr-4' ]) : array<string|int, mixed>
Parameters
- $composerDir : string
-
This value should be the directory that contains composer.json
- $namespace : string
-
The namespace to search
- $autoloaderSection : string = 'autoload'
-
Default autoload, can be other section autoloader loaded in composer.json, for example 'autoload-dev'
- $psr : string = 'psr-4'
-
Default psr-4, can be other standard loaded in composer.json
Tags
Return values
array<string|int, mixed> —getClassName()
Return correct class name using the namespace.
private
static getClassName(string $namespace, string $fileName) : string
Parameters
- $namespace : string
- $fileName : string
Return values
string —getDefinedNamespaces()
Return the standard autoload psr-4 definition in composer.json.
private
static getDefinedNamespaces(string $composerDir, string $autoloaderSection, string $psr) : array<string|int, mixed>
Parameters
- $composerDir : string
- $autoloaderSection : string
-
Default autoload, can be other section autoloader loaded in composer.json, for example 'autoload-dev'
- $psr : string
-
Default psr-4, can be other standard loaded in composer.json
Tags
Return values
array<string|int, mixed> —getNamespaceDirectory()
Returns the namespace directory if it exists or false otherwise.
private
static getNamespaceDirectory(string $composerDir, string $namespace, string $autoloaderSection, string $psr) : string
Parameters
- $composerDir : string
- $namespace : string
- $autoloaderSection : string
-
Default autoload, can be other section autoloader loaded in composer.json, for example 'autoload-dev'
- $psr : string
-
Default psr-4, can be other standard loaded in composer.json
Return values
string —listAllFiles()
A simple recursive function to list all files and subdirectories in a directory.
private
static listAllFiles(string $directory[, string $prefix = '' ]) : array<string|int, mixed>
Only return the name of the files in relative path.
Parameters
- $directory : string
- $prefix : string = ''
-
Its used for use relative paths