Skip to content

Cookbook: Methods and Options

Chris Putnam edited this page Sep 2, 2019 · 1 revision

Documentation of Methods and Options

Define a protected property with the same name as the option or method, with prefix of "__" for options, or "___" for methods, and with an array as the defined value.

The first element should be the help text. If this is the only element needed (eg. for methods with no argument) this can be a string instead of a single element array. For example:

protected $__sync = "Sync config files based on 'sync' config/option value";

For methods with arguments, after the first entry, there must be an entry for each argument, in the form of another array:

...
["Help text", "type: (boolean)|float|integer|string|...", "(optional)|required|..."]
...

These should be in the same order as the arguments in the method definition.

For example:

protected $__help = [
    "Show help/usage information.",
    ["Name of method to provide specific in-depth help", "string", "optional"],
];

Treat an option just like the value array for the argument of a method. For example:

protected $__stamp_lines = [
    "Stamp output lines",
    "boolean",
    "optional",
];

Note that the default type is "boolean" and the default validation is "optional" - so those last two examples may be defined as follows:

protected $__help = [
    "Show help/usage information.",
    ["Name of method to provide specific in-depth help", "string"],
];

// Note, as mentioned above, since there's just one element, we can also make this a string
protected $__stamp_lines = "Stamp output lines";

Clone this wiki locally