WP_CLI\DocParser::get_param_desc PHP Method

get_param_desc() public method

Get the description for a given parameter.
public get_param_desc ( string $key ) : string
$key string Parameter's key.
return string
    public function get_param_desc($key)
    {
        if (preg_match("/\\[?--{$key}=.+\n: (.+?)(\n|\$)/", $this->docComment, $matches)) {
            return $matches[1];
        }
        return '';
    }

Usage Example

Example #1
0
    function test_complete()
    {
        $doc = new DocParser(<<<EOB
/**
 * Rock and roll!
 *
 * ## OPTIONS
 *
 * <genre>...
 * : Start with one or more genres.
 *
 * --volume=<number>
 * : Sets the volume.
 *
 * --artist=<artist-name>
 * : Limit to a specific artist.
 *
 * ## 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('Start with one or more genres.', $doc->get_arg_desc('genre'));
        $this->assertEquals('Sets the volume.', $doc->get_param_desc('volume'));
        $this->assertEquals('rock-on', $doc->get_tag('alias'));
        $longdesc = <<<EOB
## OPTIONS

<genre>...
: Start with one or more genres.

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

--artist=<artist-name>
: Limit to a specific artist.

## EXAMPLES

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