\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 : string[]

Type

string[] —

Methods

find()

find(\phpDocumentor\Descriptor\Tag\ExampleDescriptor  $descriptor) : string

Attempts to find the example contents for the given descriptor.

Parameters

\phpDocumentor\Descriptor\Tag\ExampleDescriptor $descriptor

Returns

string —

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(string[]  $directories = []) : void

Registers a series of directories that may contain examples.

Parameters

string[] $directories

getExampleDirectories()

getExampleDirectories() : string[]

Returns a series of directories that may contain examples.

Returns

string[] —

getExampleFileContents()

getExampleFileContents(string  $filename) : ?string[]

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[] —

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 —