Horde_Imap_Client_Tokenize::addLiteralStream PHP Method

addLiteralStream() public method

Add data to literal stream at the current position.
public addLiteralStream ( mixed $data )
$data mixed Data to add (string, resource, or Horde_Stream object).
    public function addLiteralStream($data)
    {
        $pos = $this->_stream->pos();
        if (!isset($this->_literals[$pos])) {
            $this->_literals[$pos] = new Horde_Stream_Temp();
        }
        $this->_literals[$pos]->add($data);
    }

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));
 }
All Usage Examples Of Horde_Imap_Client_Tokenize::addLiteralStream