Finder

in package

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

Properties

private$sourceDirectory  : string                

private$exampleDirectories  : string[]                

Methods

Attempts to find the example contents for the given descriptor.

publicfind(ExampleDescriptor $descriptor) : string

Parameters

$descriptor : ExampleDescriptor

Returns

string

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

publicsetSourceDirectory([string $directory = '' ]) : void

Parameters

$directory : string = ''

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

publicgetSourceDirectory() : string

Returns

string

Registers a series of directories that may contain examples.

publicsetExampleDirectories([string[] $directories = [] ]) : void

Parameters

$directories : string[] = []

Returns a series of directories that may contain examples.

publicgetExampleDirectories() : string[]

Returns

string[]

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

privategetExampleFileContents(string $filename) : array

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

$filename : string

Returns

array

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

privategetExamplePathFromExampleDirectory(string $file) : string

Parameters

$file : string

Returns

string

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

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

.

Parameters

$directory : string
$file : string

Returns

string

Get example filepath based on sourcecode.

privategetExamplePathFromSource(string $file) : string

Parameters

$file : string

Returns

string