Webmozart\Console\Api\Args\RawArgs::getTokens PHP Method

getTokens() public method

Returns the tokens of the console arguments.
public getTokens ( ) : string[]
return string[] The argument tokens.
    public function getTokens();

Usage Example

Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getParameterOption($values, $default = false, $onlyParams = false)
 {
     $tokens = $this->rawArgs->getTokens();
     foreach ((array) $values as $value) {
         for (reset($tokens); null !== key($tokens); next($tokens)) {
             $token = current($tokens);
             if ($onlyParams && $token === '--') {
                 // end of options (--) signal reached, stop now
                 return $default;
             }
             // Long/short option with value in the next argument
             if ($token === $value) {
                 $next = next($tokens);
                 return $next && $next !== '--' ? $next : null;
             }
             // Long option with =
             if (0 === strpos($token, $value . '=')) {
                 return substr($token, strlen($value) + 1);
             }
             // Short option
             if (strlen($token) > 2 && '-' === $token[0] && '-' !== $token[1] && 0 === strpos($token, $value)) {
                 return substr($token, 2);
             }
         }
     }
     return $default;
 }
All Usage Examples Of Webmozart\Console\Api\Args\RawArgs::getTokens