Skip to content

Commit

Permalink
Bugfix: ByteBuffer->equals
Browse files Browse the repository at this point in the history
  • Loading branch information
lbuchs committed Nov 15, 2022
1 parent de1a694 commit b57d37f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Binary/ByteBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,18 @@ public function getBinaryString(): string {
}

/**
* @param string $buffer
* @param string|ByteBuffer $buffer
* @return bool
*/
public function equals($buffer): bool {
return is_string($this->_data) && $this->_data === $buffer->data;
if (is_object($buffer) && $buffer instanceof ByteBuffer) {
return $buffer->getBinaryString() === $this->getBinaryString();

} else if (is_string($buffer)) {
return $buffer === $this->getBinaryString();
}

return false;
}

/**
Expand Down

0 comments on commit b57d37f

Please sign in to comment.