*/ private array $data = []; public function __construct(private readonly string $statusTag) { } public function addLine(Line $line): void { if ($line instanceof Status && $line->tag === $this->statusTag) { $this->status = $line; return; } $this->data[] = $line; } public function hasStatus(): bool { return $this->status !== null; } public function build(): Response { if (null === $this->status) { throw new BadMethodCallException(); } return new Response( $this->status, $this->data, ); } }