@@ -35,17 +35,17 @@ public function readByte()
3535
3636 public function readUnsignedByte ()
3737 {
38- return ( int ) sprintf ( ' %u ' , ord ( $ this ->read (1 )));
38+ return current ( unpack ( ' C ' , $ this ->read (1 )));
3939 }
4040
4141 public function readUnsignedInt ()
4242 {
43- return base_convert ( bin2hex ( $ this ->read (4 )), 16 , 10 );
43+ return current ( unpack ( ' N ' , $ this ->read (4 )));
4444 }
4545
4646 public function readUnsignedShort ()
4747 {
48- return ( int ) sprintf ( ' %u ' , hexdec ( bin2hex ( $ this ->read (2 ) )));
48+ return current ( unpack ( ' n ' , $ this ->read (2 )));
4949 }
5050
5151 public function readInt ()
@@ -57,16 +57,12 @@ public function readInt()
5757 public function readShort ()
5858 {
5959 $ short = $ this ->readUnsignedShort ();
60- return (($ short & 0x8000 ) > 0 ) ? ($ short - 0xFFFF - 1 ) : $ short ;
60+ return (($ short & 0x8000 ) > 0 ) ? ($ short - 0xFFFF - 1 ) : $ short ;
6161 }
6262
6363 public function readUnsignedLong ()
6464 {
65- if (PHP_INT_MAX === 2147483647 ) {
66- return base_convert (bin2hex ($ this ->read (8 )), 16 , 10 );
67- }
68-
69- return (int ) sprintf ('%u ' , hexdec (bin2hex ($ this ->read (8 ))));
65+ return current (unpack ('J ' , $ this ->read (8 )));
7066 }
7167
7268 public function readLong ()
0 commit comments