Horde_Imap_Client_Tokenize::nextStream PHP Method

nextStream() public method

Force return of literal data as stream, if next token.
See also: next()
public nextStream ( )
    public function nextStream()
    {
        $changed = $this->_literalStream;
        $this->_literalStream = true;
        $out = $this->next();
        if ($changed) {
            $this->_literalStream = false;
        }
        return $out;
    }

Usage Example

Example #1
0
 public function testLiteralStream()
 {
     $token = new Horde_Imap_Client_Tokenize();
     $token->add('FOO {10}');
     $token->addLiteralStream('1234567890');
     $token->add(' BAR');
     $token->rewind();
     $this->assertEquals('FOO', $token->next());
     /* Internal stream is converted to string. */
     $this->assertEquals('1234567890', $token->next());
     $this->assertEquals('BAR', $token->next());
     $this->assertTrue($token->eos);
     /* Check to see stream is returned if nextStream() is called and
      * a literal is encountered. */
     $token->rewind();
     $this->assertEquals('FOO', $token->nextStream());
     $stream = $token->nextStream();
     $this->assertInstanceOf('Horde_Stream_Temp', $stream);
     $this->assertEquals('1234567890', strval($stream));
     $this->assertEquals('BAR', $token->nextStream());
     $token = new Horde_Imap_Client_Tokenize();
     $token->add('{200}' . str_repeat('Z', 200));
     $token->rewind();
     $this->assertEquals(str_repeat('Z', 200), $token->next());
     $token->rewind();
     $stream = $token->nextStream();
     $this->assertInstanceOf('Horde_Stream_Temp', $stream);
     $this->assertEquals(str_repeat('Z', 200), strval($stream));
 }