Redaxscript\Console\Parser::getOption PHP Method

getOption() public method

get item from options
Since: 3.0.0
public getOption ( string $key = null ) : mixed
$key string key of the item
return mixed
    public function getOption($key = null)
    {
        if (array_key_exists($key, $this->_optionArray)) {
            return $this->_optionArray[$key];
        } else {
            if (!$key) {
                return $this->_optionArray;
            }
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * run the command
  *
  * @param string $mode name of the mode
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function run($mode = null)
 {
     $parser = new Parser($this->_request);
     $parser->init($mode);
     /* run command */
     $argumentKey = $parser->getArgument(1);
     if ($argumentKey === 'clear') {
         return $this->_clear($parser->getOption());
     }
     if ($argumentKey === 'clear-invalid') {
         return $this->_clearInvalid($parser->getOption());
     }
     return $this->getHelp();
 }
All Usage Examples Of Redaxscript\Console\Parser::getOption