Skip to content

Commit b57d37f

Browse files
committed
Bugfix: ByteBuffer->equals
1 parent de1a694 commit b57d37f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Binary/ByteBuffer.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,18 @@ public function getBinaryString(): string {
186186
}
187187

188188
/**
189-
* @param string $buffer
189+
* @param string|ByteBuffer $buffer
190190
* @return bool
191191
*/
192192
public function equals($buffer): bool {
193-
return is_string($this->_data) && $this->_data === $buffer->data;
193+
if (is_object($buffer) && $buffer instanceof ByteBuffer) {
194+
return $buffer->getBinaryString() === $this->getBinaryString();
195+
196+
} else if (is_string($buffer)) {
197+
return $buffer === $this->getBinaryString();
198+
}
199+
200+
return false;
194201
}
195202

196203
/**

0 commit comments

Comments
 (0)