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);
 }