-
-
Notifications
You must be signed in to change notification settings - Fork 166
Expand file tree
/
Copy pathProcessResult.php
More file actions
42 lines (36 loc) · 916 Bytes
/
ProcessResult.php
File metadata and controls
42 lines (36 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Tempest\Process;
use Symfony\Component\Process\Process as SymfonyProcess;
/**
* Represents the result of a terminated process.
*/
final readonly class ProcessResult
{
public function __construct(
public int $exitCode,
public string $output,
public string $errorOutput,
) {}
/**
* Determines whether the process was successful.
*/
public function successful(): bool
{
return $this->exitCode === 0;
}
/**
* Determines whether the process has failed.
*/
public function failed(): bool
{
return ! $this->successful();
}
public static function fromSymfonyProcess(SymfonyProcess $process): self
{
return new self(
exitCode: $process->getExitCode() ?? -1,
output: $process->getOutput(),
errorOutput: $process->getErrorOutput(),
);
}
}