ConsoleTerminateEvent.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Event;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. /**
  15. * Allows to manipulate the exit code of a command after its execution.
  16. *
  17. * @author Francesco Levorato <git@flevour.net>
  18. */
  19. final class ConsoleTerminateEvent extends ConsoleEvent
  20. {
  21. private $exitCode;
  22. public function __construct(Command $command, InputInterface $input, OutputInterface $output, int $exitCode)
  23. {
  24. parent::__construct($command, $input, $output);
  25. $this->setExitCode($exitCode);
  26. }
  27. public function setExitCode(int $exitCode): void
  28. {
  29. $this->exitCode = $exitCode;
  30. }
  31. public function getExitCode(): int
  32. {
  33. return $this->exitCode;
  34. }
  35. }