/** * Attempts to read from the input channel in the stored `ReadIntent`. * * @return mixed */ protected function attemptRead() { if ($this->isReading()) { $data = $this->read($this->readIntent->getChannel()); if ($data) { $this->readIntent = null; } return $data; } }
/** * Handles the generator response. * * @param OutputIntent|ReadIntent|null $data * * @return boolean * * @throws InvalidBufferException */ private function handleResponse($data) { if ($data instanceof OutputIntent) { try { $this->write($data->getChannel(), $data->getContent()); } catch (InvalidBufferException $e) { $this->invalidate(); } } if ($data instanceof ReadIntent) { $this->readIntent = $data; } elseif ($data === null) { $this->invalidate(); return null; } return true; }