You are here

public function Input::validate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Input/Input.php \Symfony\Component\Console\Input\Input::validate()

Validates the input.

Throws

\RuntimeException When not enough arguments are given

Overrides InputInterface::validate

1 call to Input::validate()
Input::__construct in vendor/symfony/console/Input/Input.php
Constructor.

File

vendor/symfony/console/Input/Input.php, line 74

Class

Input
Input is the base class for all concrete Input classes.

Namespace

Symfony\Component\Console\Input

Code

public function validate() {
  $definition = $this->definition;
  $givenArguments = $this->arguments;
  $missingArguments = array_filter(array_keys($definition
    ->getArguments()), function ($argument) use ($definition, $givenArguments) {
    return !array_key_exists($argument, $givenArguments) && $definition
      ->getArgument($argument)
      ->isRequired();
  });
  if (count($missingArguments) > 0) {
    throw new \RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  }
}