@@ -61,11 +61,11 @@ public function Remaining( ) : int
6161 }
6262
6363 /**
64- * Gets data from buffer
64+ * Reads the specified number of bytes.
6565 *
6666 * @param int $Length Bytes to read
6767 */
68- public function Get ( int $ Length = -1 ) : string
68+ public function Read ( int $ Length = -1 ) : string
6969 {
7070 if ( $ Length === 0 )
7171 {
@@ -91,97 +91,97 @@ public function Get( int $Length = -1 ) : string
9191 }
9292
9393 /**
94- * Get byte from buffer
94+ * Reads the next byte.
9595 */
96- public function GetByte ( ) : int
96+ public function ReadByte ( ) : int
9797 {
98- return ord ( $ this ->Get ( 1 ) );
98+ return ord ( $ this ->Read ( 1 ) );
9999 }
100100
101101 /**
102- * Get short from buffer
102+ * Reads a 2-byte signed integer.
103103 */
104- public function GetShort ( ) : int
104+ public function ReadInt16 ( ) : int
105105 {
106106 if ( $ this ->Remaining ( ) < 2 )
107107 {
108- throw new InvalidPacketException ( 'Not enough data to unpack a short . ' , InvalidPacketException::BUFFER_EMPTY );
108+ throw new InvalidPacketException ( 'Not enough data to unpack. ' , InvalidPacketException::BUFFER_EMPTY );
109109 }
110110
111- $ Data = unpack ( 'v ' , $ this ->Get ( 2 ) );
111+ $ Data = unpack ( 'v ' , $ this ->Read ( 2 ) );
112112
113113 if ( $ Data === false )
114114 {
115- throw new InvalidPacketException ( 'Failed to unpack a short . ' , InvalidPacketException::UNPACK_FAILED );
115+ throw new InvalidPacketException ( 'Failed to unpack. ' , InvalidPacketException::UNPACK_FAILED );
116116 }
117117
118118 return (int )$ Data [ 1 ];
119119 }
120120
121121 /**
122- * Get long from buffer
122+ * Reads a 4-byte signed integer.
123123 */
124- public function GetLong ( ) : int
124+ public function ReadInt32 ( ) : int
125125 {
126126 if ( $ this ->Remaining ( ) < 4 )
127127 {
128- throw new InvalidPacketException ( 'Not enough data to unpack a long . ' , InvalidPacketException::BUFFER_EMPTY );
128+ throw new InvalidPacketException ( 'Not enough data to unpack. ' , InvalidPacketException::BUFFER_EMPTY );
129129 }
130130
131- $ Data = unpack ( 'l ' , $ this ->Get ( 4 ) );
131+ $ Data = unpack ( 'l ' , $ this ->Read ( 4 ) );
132132
133133 if ( $ Data === false )
134134 {
135- throw new InvalidPacketException ( 'Failed to unpack a long . ' , InvalidPacketException::UNPACK_FAILED );
135+ throw new InvalidPacketException ( 'Failed to unpack. ' , InvalidPacketException::UNPACK_FAILED );
136136 }
137137
138138 return (int )$ Data [ 1 ];
139139 }
140140
141141 /**
142- * Get float from buffer
142+ * Reads a 4-byte floating point value.
143143 */
144- public function GetFloat ( ) : float
144+ public function ReadFloat32 ( ) : float
145145 {
146146 if ( $ this ->Remaining ( ) < 4 )
147147 {
148- throw new InvalidPacketException ( 'Not enough data to unpack a float . ' , InvalidPacketException::BUFFER_EMPTY );
148+ throw new InvalidPacketException ( 'Not enough data to unpack. ' , InvalidPacketException::BUFFER_EMPTY );
149149 }
150150
151- $ Data = unpack ( 'f ' , $ this ->Get ( 4 ) );
151+ $ Data = unpack ( 'f ' , $ this ->Read ( 4 ) );
152152
153153 if ( $ Data === false )
154154 {
155- throw new InvalidPacketException ( 'Failed to unpack a float . ' , InvalidPacketException::UNPACK_FAILED );
155+ throw new InvalidPacketException ( 'Failed to unpack. ' , InvalidPacketException::UNPACK_FAILED );
156156 }
157157
158158 return (float )$ Data [ 1 ];
159159 }
160160
161161 /**
162- * Get unsigned long from buffer
162+ * Reads a 4-byte unsigned integer.
163163 */
164- public function GetUnsignedLong ( ) : int
164+ public function ReadUInt32 ( ) : int
165165 {
166166 if ( $ this ->Remaining ( ) < 4 )
167167 {
168- throw new InvalidPacketException ( 'Not enough data to unpack an usigned long . ' , InvalidPacketException::BUFFER_EMPTY );
168+ throw new InvalidPacketException ( 'Not enough data to unpack. ' , InvalidPacketException::BUFFER_EMPTY );
169169 }
170170
171- $ Data = unpack ( 'V ' , $ this ->Get ( 4 ) );
171+ $ Data = unpack ( 'V ' , $ this ->Read ( 4 ) );
172172
173173 if ( $ Data === false )
174174 {
175- throw new InvalidPacketException ( 'Failed to unpack a ulong . ' , InvalidPacketException::UNPACK_FAILED );
175+ throw new InvalidPacketException ( 'Failed to unpack. ' , InvalidPacketException::UNPACK_FAILED );
176176 }
177177
178178 return (int )$ Data [ 1 ];
179179 }
180180
181181 /**
182- * Read one string from buffer ending with null byte
182+ * Read a null-terminated string.
183183 */
184- public function GetString ( ) : string
184+ public function ReadNullTermString ( ) : string
185185 {
186186 $ ZeroBytePosition = strpos ( $ this ->Buffer , "\0" , $ this ->Position );
187187
@@ -190,7 +190,7 @@ public function GetString( ) : string
190190 return '' ;
191191 }
192192
193- $ String = $ this ->Get ( $ ZeroBytePosition - $ this ->Position );
193+ $ String = $ this ->Read ( $ ZeroBytePosition - $ this ->Position );
194194
195195 $ this ->Position ++;
196196
0 commit comments