Debian Codegraph @

vendor/symfony/console/Event/ConsoleSignalEvent.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 /**
19 * @author marie <[email protected]>
20 */
21 final class ConsoleSignalEvent extends ConsoleEvent
22 {
23 public function __construct(
24 Command $command,
25 InputInterface $input,
26 OutputInterface $output,
27 private int $handlingSignal,
28 private int|false $exitCode = 0,
29 ) {
30 parent::__construct($command, $input, $output);
31 }
32
33 public function getHandlingSignal(): int
34 {
35 return $this->handlingSignal;
36 }
37
38 public function setExitCode(int $exitCode): void
39 {
40 if ($exitCode < 0 || $exitCode > 255) {
41 throw new \InvalidArgumentException('Exit code must be between 0 and 255.');
42 }
43
44 $this->exitCode = $exitCode;
45 }
46
47 public function abortExit(): void
48 {
49 $this->exitCode = false;
50 }
51
52 public function getExitCode(): int|false
53 {
54 return $this->exitCode;
55 }
56 }