GetOptionKit\Argument::anyOfOptions PHP Méthode

anyOfOptions() public méthode

Check if an option is one of the option in the collection.
public anyOfOptions ( OptionCollection $options )
$options OptionCollection
    public function anyOfOptions(OptionCollection $options)
    {
        $name = $this->getOptionName();
        $keys = $options->keys();
        return in_array($name, $keys);
    }

Usage Example

Exemple #1
0
 /**
  * preprocess the argv array
  *
  * - split option and option value
  * - separate arguments after "--"
  */
 protected function preprocessingArguments(array $argv)
 {
     // preprocessing arguments
     $newArgv = array();
     $extra = array();
     $afterDash = false;
     foreach ($argv as $arg) {
         if ($arg === '--') {
             $afterDash = true;
             continue;
         }
         if ($afterDash) {
             $extra[] = $arg;
             continue;
         }
         $a = new Argument($arg);
         if ($a->anyOfOptions($this->specs) && $a->containsOptionValue()) {
             list($opt, $val) = $a->splitAsOption();
             array_push($newArgv, $opt, $val);
         } else {
             $newArgv[] = $arg;
         }
     }
     return array($newArgv, $extra);
 }