public function testItReturnsLinesFromInjectedArrayAccessInstance() { $response = $this->getMock('Rvdv\\Nntp\\Response\\ResponseInterface'); $lines = new \SplFixedArray(); $multiLineResponse = new MultiLineResponse($response, $lines); $this->assertSame($lines, $multiLineResponse->getLines()); }
/** * Called when the list is received from the server. * * @param MultiLineResponse $response */ public function onListFollows(MultiLineResponse $response) { $lines = $response->getLines(); $totalLines = count($lines); for ($i = 0; $i < $totalLines; ++$i) { list($name, $high, $low, $status) = explode(' ', $lines[$i]); $this->result[$i] = ['name' => $name, 'high' => $high, 'low' => $low, 'status' => $status]; } }
public function onInformationFollows(MultiLineResponse $response) { $this->result = []; foreach ($response->getLines() as $line) { if (0 == strcasecmp(substr($line, -5, 5), ':full')) { // ':full' is _not_ included in tag, but value set to true $this->result[str_replace('-', '_', strtolower(substr($line, 0, -5)))] = true; } else { // ':' is _not_ included in tag; value set to false $this->result[str_replace('-', '_', strtolower(substr($line, 0, -1)))] = false; } } }
public function onOverviewInformationFollows(MultiLineResponse $response) { $lines = $response->getLines(); $totalLines = count($lines); for ($i = 0; $i < $totalLines; ++$i) { $segments = explode("\t", $lines[$i]); $field = 0; $message = []; foreach ($this->format as $name => $full) { $value = $full ? ltrim(substr($segments[$field], strpos($segments[$field], ':') + 1), " \t") : $segments[$field]; $message[$name] = $value; ++$field; } $this->result[$i] = $message; } unset($lines); }
public function onBodyFollows(MultiLineResponse $response) { $lines = $response->getLines(); $this->result = implode("\r\n", $lines->toArray()); }
/** * Called when help text is received from server. * * @param MultiLineResponse $response */ public function onHelpTextFollow(MultiLineResponse $response) { $this->result = implode("\n", (array) $response->getLines()); }