the frames received, as on the wire without the line end */ public array $received = []; public bool $closed = false; /** the address the tests give this client */ public string $ip = ''; public function __construct(private readonly string $name = 'memory') { } public function send(string $code, array $fields = []): void { if (!$this->closed) { $this->received[] = rtrim(Frame::encode($code, $fields), "\n"); } } public function close(): void { $this->closed = true; } public function address(): string { return $this->name; } public function ip(): string { return $this->ip; } /** @return list the frames of that code, without their code */ public function frames(string $code): array { $out = []; foreach ($this->received as $line) { if (str_starts_with($line, $code . "\t")) { $out[] = substr($line, strlen($code) + 1); } } return $out; } /** @return list and forgets them */ public function take(): array { $lines = $this->received; $this->received = []; return $lines; } }