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

CloneableInstantiable
Methods
public find(phpDocumentor\Reflection\DocBlock\Tags\Example $example) : string
 

Attempts to find the example contents for the given descriptor.

public getExampleDirectories() : array
 

Returns a series of directories that may contain examples.

  • return string[]
public getSourceDirectory() : string
 

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

public setExampleDirectories(array $directories) : void
 

Registers a series of directories that may contain examples.

    public setSourceDirectory(string $directory = '') : void
     

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

    Properties
    private $exampleDirectories
     
    • var string[]
    private $sourceDirectory
     
    • var string
    Methods
    private constructExamplePath(string $directory, string $file) : string
     

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

    .

    private getExampleFileContents(string $filename) : array
     

    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
    • return string[] all lines of the example file
    private getExamplePathFromExampleDirectory(string $file) : string
     

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

    private getExamplePathFromSource(string $file) : string
     

    Get example filepath based on sourcecode.

    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only