lib/AdobeMarketingCloud/OptionParser.php
public function addRule()
    {
        $args = func_get_args();
        $rule = array(
            'description'   => '',
            'callback'      => null,
            'required'      => self::PARAM_NOTREQUIRED
        );

        $flags = array_shift($args);

        if ($this->_config & self::CONF_IGNORECASE) {
            $flags = strtolower($flags);
        }

        if (preg_match('/::?$/', $flags, $match)) {
            if (strlen($match[0]) == 2) {
                $rule['required'] = self::PARAM_REQUIRED;
            } else {
                $rule['required'] = self::PARAM_OPTIONAL;
            }
            $flags = rtrim($flags, ':');
        }

        # consume the remaining arguments
        while (count($args)) {
            $arg = array_pop($args);
            if (is_callable($arg)) {
                $rule['callback'] = $arg;
            } elseif (is_string($arg)) {
                $rule['description'] = $arg;
            }
        }

        $ruleIndex = count($this->_rules);

        foreach (explode('|', $flags) as $flag) {
            if ($flag) {
                $this->_flags[$flag] = $ruleIndex;
            }
        }

        $this->_rules[] = $rule;
    }
public function addRule()
    {
        $args = func_get_args();
        $rule = array(
            'description'   => '',
            'callback'      => null,
            'required'      => self::PARAM_NOTREQUIRED
        );

        $flags = array_shift($args);

        if ($this->_config & self::CONF_IGNORECASE) {
            $flags = strtolower($flags);
        }

        if (preg_match('/::?$/', $flags, $match)) {
            if (strlen($match[0]) == 2) {
                $rule['required'] = self::PARAM_REQUIRED;
            } else {
                $rule['required'] = self::PARAM_OPTIONAL;
            }
            $flags = rtrim($flags, ':');
        }

        # consume the remaining arguments
        while (count($args)) {
            $arg = array_pop($args);
            if (is_callable($arg)) {
                $rule['callback'] = $arg;
            } elseif (is_string($arg)) {
                $rule['description'] = $arg;
            }
        }

        $ruleIndex = count($this->_rules);

        foreach (explode('|', $flags) as $flag) {
            if ($flag) {
                $this->_flags[$flag] = $ruleIndex;
            }
        }

        $this->_rules[] = $rule;
    }
Adds a rule to this option parser. A rule consists of some flags that have
an optional description and/or callback function associated with them. The first
argument to this function should be the rule flags in a string seperated by a
pipe (|) character. The string may end in a colon (:) to indicate that the flag
accepts an optional parameter, or two colons (::) for a required parameter.
Remaining arguments may be a description, a callback function, both, or neither.

If a description is given it will be used in the usage message for this parser
when describing this rule. If a callback function is given, it will be called when
any of the flags for this option are encountered in the arguments. Some examples
follow:

<code>
$parser = new OptionParser;
$parser->addRule('a');
$parser->addRule('long-option');
$parser->addRule('b::'); // "b" with required parameter
$parser->addRule('q|quiet', "Don't output to the console"); // "q" or "quiet" with description
$parser->addRule('c', 'my_callback'); // my_callback will be called if the "c" flag is used
$parser->addRule('o|output:'); // "o" or "output" with optional parameter
</code>

@param   string  $flags  The rule flags
@param   mixed   ...     The rule description or callback
@return  void