Stecman\Component\Symfony\Console\BashCompletion\CompletionContext::getWordAtIndex PHP Метод

getWordAtIndex() публичный Метод

Return a word by index from the command line
public getWordAtIndex ( integer $index ) : string
$index integer
Результат string
    public function getWordAtIndex($index)
    {
        if (isset($this->words[$index])) {
            return $this->words[$index];
        }
        return '';
    }

Usage Example

 /**
  * Attemp to complete the current word as the value of a long-form option
  *
  * @return array|false
  */
 protected function completeForOptionValues()
 {
     $wordIndex = $this->context->getWordIndex();
     if ($this->command && $wordIndex > 1) {
         $left = $this->context->getWordAtIndex($wordIndex - 1);
         if (strpos($left, '--') === 0) {
             $name = substr($left, 2);
             $def = $this->command->getNativeDefinition();
             if (!$def->hasOption($name)) {
                 return false;
             }
             $opt = $def->getOption($name);
             if ($opt->isValueRequired() || $opt->isValueOptional()) {
                 return $this->completeOption($opt);
             }
         }
     }
     return false;
 }
All Usage Examples Of Stecman\Component\Symfony\Console\BashCompletion\CompletionContext::getWordAtIndex