getSize() 공개 메소드

Get the size of the stream
public getSize ( ) : integer | null
리턴 integer | null Returns the size in bytes if known
예제 #1
0
 public function testGetSize()
 {
     $handle = fopen('php://temp', 'w+');
     $stream = new Stream($handle);
     $this->assertEquals(3, fwrite($handle, 'foo'));
     $this->assertEquals(3, $stream->getSize());
     $this->assertEquals(4, $stream->write('test', strlen('test')));
     $this->assertEquals(7, $stream->getSize());
     $this->assertEquals(7, $stream->getSize());
 }
예제 #2
0
 /**
  * Compute the number of bytes that would be needed to encode a stream of bytes.
  *
  * @param \Protobuf\Stream $value
  *
  * @return integer
  */
 public function computeByteStreamSize(Stream $value)
 {
     $length = $value->getSize();
     $size = $length + $this->computeVarintSize($length);
     return $size;
 }
예제 #3
0
 /**
  * Write the given stream.
  *
  * @param \Protobuf\Stream $stream
  * @param \Protobuf\Stream $value
  * @param int              $length
  */
 public function writeStream(Stream $stream, Stream $value, $length = null)
 {
     if ($length === null) {
         $length = $value->getSize();
     }
     $stream->writeStream($value, $length);
 }