File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ class Binary
6565 /**
6666 * 字符串转为字节组
6767 *
68- * @param string $string
68+ * @param string $string 二进制流/明文字符串
6969 * @return int[]
7070 */
7171 public static function StringToBytes (string $ string ): array
@@ -80,7 +80,7 @@ public static function StringToBytes(string $string): array
8080 * 字节组转为字符串
8181 *
8282 * @param array $bytes
83- * @return string
83+ * @return string 二进制流/明文字符串
8484 */
8585 public static function BytesToString (array $ bytes ): string
8686 {
@@ -139,14 +139,6 @@ public function __construct(mixed $payload = null)
139139 }
140140 }
141141
142- /**
143- * @return mixed
144- */
145- public function getPayload (): mixed
146- {
147- return $ this ->payload ;
148- }
149-
150142 /**
151143 * 获取读指针的位置
152144 *
@@ -195,6 +187,14 @@ public function setWriteCursor(int $position): void
195187 $ this ->writeCursor = $ position ;
196188 }
197189
190+ /**
191+ * @return mixed
192+ */
193+ public function payload (): mixed
194+ {
195+ return $ this ->payload ;
196+ }
197+
198198 /**
199199 * 将payload转换为字节数组
200200 *
@@ -213,7 +213,7 @@ public function unpack(): array
213213 public function pack (): string
214214 {
215215 if ($ this ->string === null ) {
216- $ this ->string = pack ( ' C* ' , ... $ this ->bytes );
216+ $ this ->string = self :: BytesToString ( $ this ->bytes );
217217 }
218218 return $ this ->string ;
219219 }
You can’t perform that action at this time.
0 commit comments