示例#1
0
 /**
  * @param string $string
  * @param null $endian
  */
 public function __construct($string = '', $endian = null)
 {
     if (!is_resource($string)) {
         $handle = fopen('php://memory', 'br+');
         fwrite($handle, $string);
         rewind($handle);
     } else {
         $handle = $string;
     }
     $this->handle = $handle;
     $this->size = fstat($this->handle)['size'];
     if ($endian === null) {
         $endian = Endian::getMachineEndian();
     }
     $this->setPosition(0)->setEndian($endian);
 }
示例#2
0
 public function testConvert()
 {
     $endian = new Endian();
     $this->assertEquals(128, $endian->convert(2147483648));
 }