Debian Codegraph @

vendor/symfony/console/Event/ConsoleAlarmEvent.php

raw
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Console\Event;
13
14 use Symfony\Component\Console\Command\Command;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Output\OutputInterface;
17
18 final class ConsoleAlarmEvent extends ConsoleEvent
19 {
20 public function __construct(
21 Command $command,
22 InputInterface $input,
23 OutputInterface $output,
24 private int|false $exitCode = 0,
25 ) {
26 parent::__construct($command, $input, $output);
27 }
28
29 public function setExitCode(int $exitCode): void
30 {
31 if ($exitCode < 0 || $exitCode > 255) {
32 throw new \InvalidArgumentException('Exit code must be between 0 and 255.');
33 }
34
35 $this->exitCode = $exitCode;
36 }
37
38 public function abortExit(): void
39 {
40 $this->exitCode = false;
41 }
42
43 public function getExitCode(): int|false
44 {
45 return $this->exitCode;
46 }
47 }