示例#1
0
 /**
  *
  * @param CommandArgument $argument
  * @param int $index
  * @return mixed
  * @throws CommandInvalidArgumentLengthException
  */
 private function getValue(CommandArgument $argument, $index)
 {
     $length = $argument->getLength();
     if ($length == 0) {
         return true;
     }
     $value = [];
     for ($i = $index + 1, $j = $length; $i < count($this->arguments) && $j > 0; $i++, $j--) {
         $value[] = $this->arguments[$i];
     }
     if ($j != 0) {
         throw new CommandInvalidArgumentLengthException($argument->getName(), $argument->getLength(), $argument->getLength() - $j);
     }
     if (count($value) == 1) {
         $value = $value[0];
     }
     return $value;
 }