You are here

public function Command::setCode in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Command/Command.php \Symfony\Component\Console\Command\Command::setCode()

Sets the code to execute when running this command.

If this method is used, it overrides the code defined in the execute() method.

Parameters

callable $code A callable(InputInterface $input, OutputInterface $output):

Return value

Command The current instance

Throws

\InvalidArgumentException

See also

execute()

File

vendor/symfony/console/Command/Command.php, line 276

Class

Command
Base class for all commands.

Namespace

Symfony\Component\Console\Command

Code

public function setCode($code) {
  if (!is_callable($code)) {
    throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.');
  }
  $this->code = $code;
  return $this;
}