Пример #1
0
 /**
  * @param int $int
  * @param int $bytes
  * @param int $endian
  * @return ByteBuffer
  */
 public function writeInt($int, $bytes = 1, $endian = null)
 {
     if ($bytes > 8) {
         throw new \LengthException("Can't write integer larger 64 bit.");
     }
     if ($bytes > 4 && !$this->can64()) {
         throw new \LengthException('Your system not support 64 bit integers.');
     }
     if ($endian === null) {
         $endian = $this->getEndian();
     }
     $str = Packer::pack(Packer::getFormat('int', $bytes * 8, false, $endian), $int);
     return $this->write($str);
 }