WP_CLI\DocParser::get_tag PHP Method

get_tag() public method

Get the value for a given tag (e.g. "@alias" or "@subcommand")
public get_tag ( string $name ) : string
$name string Name for the tag, without '@'
return string
    public function get_tag($name)
    {
        if (preg_match('|^@' . $name . '\\s+([a-z-_]+)|m', $this->docComment, $matches)) {
            return $matches[1];
        }
        return '';
    }

Usage Example

Example #1
0
    function test_complete()
    {
        $doc = new DocParser(<<<EOB
/**
 * Rock and roll!
 *
 * ## OPTIONS
 *
 * --volume=<number>
 * : Sets the volume.
 *
 * ## EXAMPLES
 *
 * wp rock-on --volume=11
 *
 * @synopsis [--volume=<number>]
 * @alias rock-on
 */
EOB
);
        $this->assertEquals('Rock and roll!', $doc->get_shortdesc());
        $this->assertEquals('[--volume=<number>]', $doc->get_synopsis());
        $this->assertEquals('rock-on', $doc->get_tag('alias'));
        $longdesc = <<<EOB
## OPTIONS

--volume=<number>
: Sets the volume.

## EXAMPLES

wp rock-on --volume=11
EOB;
        $this->assertEquals($longdesc, $doc->get_longdesc());
    }
All Usage Examples Of WP_CLI\DocParser::get_tag