Finder
in package
Class used to find an example file's location based on a given ExampleDescriptor.
Table of Contents
Properties
- $exampleDirectories : array<string|int, string>
- $sourceDirectory : string
Methods
- find() : string
- Attempts to find the example contents for the given descriptor.
- getExampleDirectories() : array<string|int, string>
- Returns a series of directories that may contain examples.
- getSourceDirectory() : string
- Returns the project's root directory where an 'examples' folder can be expected.
- setExampleDirectories() : void
- Registers a series of directories that may contain examples.
- setSourceDirectory() : void
- Registers the project's root directory where an 'examples' folder can be expected.
- constructExamplePath() : string
- Returns a path to the example file in the given directory.
- getExampleFileContents() : array<string|int, string>|null
- Attempts to find the requested example file and returns its contents or null if no file was found.
- getExamplePathFromExampleDirectory() : string
- Get example filepath based on the example directory inside your project.
- getExamplePathFromSource() : string
- Get example filepath based on sourcecode.
Properties
$exampleDirectories
private
array<string|int, string>
$exampleDirectories
= []
$sourceDirectory
private
string
$sourceDirectory
= ''
Methods
find()
Attempts to find the example contents for the given descriptor.
public
find(ExampleDescriptor $descriptor) : string
Parameters
- $descriptor : ExampleDescriptor
Return values
stringgetExampleDirectories()
Returns a series of directories that may contain examples.
public
getExampleDirectories() : array<string|int, string>
Return values
array<string|int, string>getSourceDirectory()
Returns the project's root directory where an 'examples' folder can be expected.
public
getSourceDirectory() : string
Return values
stringsetExampleDirectories()
Registers a series of directories that may contain examples.
public
setExampleDirectories([array<string|int, string> $directories = [] ]) : void
Parameters
- $directories : array<string|int, string> = []
setSourceDirectory()
Registers the project's root directory where an 'examples' folder can be expected.
public
setSourceDirectory([string $directory = '' ]) : void
Parameters
- $directory : string = ''
constructExamplePath()
Returns a path to the example file in the given directory.
private
constructExamplePath(string $directory, string $file) : string
.
Parameters
- $directory : string
- $file : string
Return values
stringgetExampleFileContents()
Attempts to find the requested example file and returns its contents or null if no file was found.
private
getExampleFileContents(string $filename) : array<string|int, string>|null
This method will try several methods in search of the given example file, the first one it encounters is returned:
- Iterates through all examples folders for the given filename
- Checks the source folder for the given filename
- Checks the 'examples' folder in the current working directory for examples
- Checks the path relative to the current working directory for the given filename
Parameters
- $filename : string
Return values
array<string|int, string>|nullgetExamplePathFromExampleDirectory()
Get example filepath based on the example directory inside your project.
private
getExamplePathFromExampleDirectory(string $file) : string
Parameters
- $file : string
Return values
stringgetExamplePathFromSource()
Get example filepath based on sourcecode.
private
getExamplePathFromSource(string $file) : string
Parameters
- $file : string