Lines
0.00%
0 / 8
Functions and Methods
0.00%
0 / 7
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ProcessContextWorker | 0.00% | 0 / 8 | 0.00% | 0 / 7 | 72 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| getPid | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| transport | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| stdout | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| stderr | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| join | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| close | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Broker; | |
| 6 | ||
| 7 | use Amp\ByteStream\ReadableStream; | |
| 8 | use Amp\Parallel\Context\ProcessContext; | |
| 9 | use Stewart\Runtime\Ipc\ChannelTransport; | |
| 10 | use Stewart\Runtime\Ipc\Transport; | |
| 11 | use Stewart\Runtime\Ipc\Wire\IpcCodec; | |
| 12 | ||
| 13 | final class ProcessContextWorker implements WorkerProcess | |
| 14 | { | |
| 15 | private readonly Transport $transport; | |
| 16 | ||
| 17 | /** @param ProcessContext<string, string, string> $context */ | |
| 18 | public function __construct(private readonly ProcessContext $context, IpcCodec $ipcCodec) | |
| 19 | { | |
| 20 | $this->transport = new ChannelTransport($context, $ipcCodec); | |
| 21 | } | |
| 22 | ||
| 23 | public function getPid(): int | |
| 24 | { | |
| 25 | return $this->context->getPid(); | |
| 26 | } | |
| 27 | ||
| 28 | public function transport(): Transport | |
| 29 | { | |
| 30 | return $this->transport; | |
| 31 | } | |
| 32 | ||
| 33 | public function stdout(): ReadableStream | |
| 34 | { | |
| 35 | return $this->context->getStdout(); | |
| 36 | } | |
| 37 | ||
| 38 | public function stderr(): ReadableStream | |
| 39 | { | |
| 40 | return $this->context->getStderr(); | |
| 41 | } | |
| 42 | ||
| 43 | public function join(): string | |
| 44 | { | |
| 45 | $summary = $this->context->join(); | |
| 46 | ||
| 47 | return \is_string($summary) ? $summary : ''; | |
| 48 | } | |
| 49 | ||
| 50 | public function close(): void | |
| 51 | { | |
| 52 | $this->context->close(); | |
| 53 | } | |
| 54 | } |