kahlan\cli\CommandLine::get PHP Method

get() public method

Gets the value of a specific option.
public get ( string $name = null ) : array
$name string The name of the option.
return array The value.
    public function get($name = null)
    {
        if (func_num_args()) {
            return $this->_get($name);
        }
        $result = [];
        foreach ($this->_values as $key => $data) {
            foreach ($data as $extra => $value) {
                if ($extra === '') {
                    $result[$key] = $this->_get($key);
                } else {
                    $result[$key][$extra] = $this->_get($key . ':' . $extra);
                }
            }
        }
        return $result;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Load the config.
  *
  * @param string $argv The command line string.
  */
 public function loadConfig($argv = [])
 {
     $commandLine = new CommandLine();
     $commandLine->option('config', ['default' => 'kahlan-config.php']);
     $commandLine->option('help', ['type' => 'boolean']);
     $commandLine->option('version', ['type' => 'boolean']);
     $commandLine->parse($argv);
     $run = function ($commandLine) {
         if (file_exists($commandLine->get('config'))) {
             require $commandLine->get('config');
         }
     };
     $run($commandLine);
     $this->_commandLine->parse($argv, false);
     if ($commandLine->get('help')) {
         return $this->_help();
     }
     if ($commandLine->get('version')) {
         return $this->_version();
     }
 }
All Usage Examples Of kahlan\cli\CommandLine::get