Google\Cloud\Dev\Snippet\Parser\Parser::methodExample PHP Method

methodExample() public method

Example: $snippet = $parser->methodExample(Parser::class, 'methodExample'); Get the 2nd example (index=1) $snippet = $parser->methodExample(Parser::class, 'methodExample', 1);
public methodExample ( string $class, string $method, integer $index ) : Snippet
$class string The name of the class.
$method string The name of the method.
$index integer The 0-indexed example to return.
return Snippet
    public function methodExample($class, $method, $index = 0)
    {
        $examples = $this->examplesFromMethod($class, $method);
        $result = array_filter($examples, function ($example) use($index) {
            return $example->index() === $index;
        });
        if (empty($result)) {
            throw new \Exception(sprintf('Given snippet index %d does not exist for method %s::%s', $index, $class, $method));
        }
        return current($result);
    }