コード例 #1
0
ファイル: VarInt.php プロジェクト: sbwdlihao/buffertools-php
 /**
  * {@inheritdoc}
  * @see \BitWasp\Buffertools\Types\TypeInterface::write()
  */
 public function write($integer)
 {
     $math = $this->getMath();
     $uint8 = new Uint8($math);
     if ($math->cmp($integer, 0xfd) < 0) {
         $int = $uint8;
     } else {
         list($int, $prefix) = $this->solveWriteSize($integer);
     }
     $prefix = isset($prefix) ? $uint8->write($prefix) : '';
     $bits = $prefix . $int->write($integer);
     return $bits;
 }