A class for parsing code snippets from a class and its methods.

Example:

use Google\Cloud\Core\Testing\Snippet\Parser\Parser;

$parser = new Parser;
CloneableInstantiable
Constants
public Google\Cloud\Core\Testing\Snippet\Parser\Parser::SNIPPET_NAME_REGEX = '/\/\/\s?\[snippet\=(\w{0,})\]/'
Methods
public allExamples( $class)
 
Retrieve all examples from a class and its methods.

Example:

$examples = $parser->allExamples($parser);
  • return array
public classExample( $class, $index = 0)
 
Get a snippet from a class.

Example:

use Google\Cloud\Core\Testing\Snippet\Parser\Parser;

$snippet = $parser->classExample(Parser::class);
public createIdentifier( $fqn, $indexOrName)
 
Create identifier

  • return string
public examples(phpDocumentor\Reflection\DocBlock $docBlock, $fullyQualifiedName, $file, $line, array $magicMethods = [])
 
Parse examples from a DocBlock object.

  • return array
public examplesFromClass( $class)
 
Retrieve all examples from a class Doc Block.

Example:

$examples = $parser->examplesFromClass($parser);
  • return array
public examplesFromMethod( $class, $method)
 
Retrieve all examples from a method's Doc Block.

Example:

$examples = $parser->examplesFromMethod($parser, 'examplesFromMethod');
  • return array
public methodExample( $class, $method, $index = 0)
 
Get a snippet from a method.

Example:

use Google\Cloud\Core\Testing\Snippet\Parser\Parser;

$snippet = $parser->methodExample(Parser::class, 'methodExample');
use Google\Cloud\Core\Testing\Snippet\Parser\Parser;

// Get the 2nd example (index=1)
$snippet = $parser->methodExample(Parser::class, 'methodExample', 1);
Methods
private buildMagicMethods( $magicMethods, $className)
private extractSnippetName( $content)
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only