\phpDocumentor\Descriptor\ExampleFinder

Class used to find an example file's location based on a given ExampleDescriptor.

Summary

Methods
Properties
Constants
find()
setSourceDirectory()
getSourceDirectory()
setExampleDirectories()
getExampleDirectories()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
getExampleFileContents()
getExamplePathFromExampleDirectory()
constructExamplePath()
getExamplePathFromSource()
$sourceDirectory
$exampleDirectories
N/A

Properties

$sourceDirectory

$sourceDirectory : string

Type

string

$exampleDirectories

$exampleDirectories : array<mixed,string>

Type

array<mixed,string>

Methods

setSourceDirectory()

setSourceDirectory(string  $directory = '') : void

Registers the project's root directory where an 'examples' folder can be expected.

Parameters

string $directory

getSourceDirectory()

getSourceDirectory() : string

Returns the project's root directory where an 'examples' folder can be expected.

Returns

string

setExampleDirectories()

setExampleDirectories(array<mixed,string>  $directories) 

Registers a series of directories that may contain examples.

Parameters

array<mixed,string> $directories

getExampleDirectories()

getExampleDirectories() : array<mixed,string>

Returns a series of directories that may contain examples.

Returns

array<mixed,string>

getExampleFileContents()

getExampleFileContents(string  $filename) : string|null

Attempts to find the requested example file and returns its contents or null if no file was found.

This method will try several methods in search of the given example file, the first one it encounters is returned:

  1. Iterates through all examples folders for the given filename
  2. Checks the source folder for the given filename
  3. Checks the 'examples' folder in the current working directory for examples
  4. Checks the path relative to the current working directory for the given filename

Parameters

string $filename

Returns

string|null

getExamplePathFromExampleDirectory()

getExamplePathFromExampleDirectory(string  $file) : string

Get example filepath based on the example directory inside your project.

Parameters

string $file

Returns

string

constructExamplePath()

constructExamplePath(string  $directory, string  $file) : string

Returns a path to the example file in the given directory.

.

Parameters

string $directory
string $file

Returns

string

getExamplePathFromSource()

getExamplePathFromSource(string  $file) : string

Get example filepath based on sourcecode.

Parameters

string $file

Returns

string