コード例 #1
0
 public function testItReturnsLinesFromInjectedArrayAccessInstance()
 {
     $response = $this->getMock('Rvdv\\Nntp\\Response\\ResponseInterface');
     $lines = new \SplFixedArray();
     $multiLineResponse = new MultiLineResponse($response, $lines);
     $this->assertSame($lines, $multiLineResponse->getLines());
 }
コード例 #2
0
ファイル: ListCommand.php プロジェクト: thebandit/php-nntp
 /**
  * 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];
     }
 }
コード例 #3
0
 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;
         }
     }
 }
コード例 #4
0
 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);
 }
コード例 #5
0
ファイル: BodyCommand.php プロジェクト: thebandit/php-nntp
 public function onBodyFollows(MultiLineResponse $response)
 {
     $lines = $response->getLines();
     $this->result = implode("\r\n", $lines->toArray());
 }
コード例 #6
0
ファイル: HelpCommand.php プロジェクト: thebandit/php-nntp
 /**
  * Called when help text is received from server.
  *
  * @param MultiLineResponse $response
  */
 public function onHelpTextFollow(MultiLineResponse $response)
 {
     $this->result = implode("\n", (array) $response->getLines());
 }