Commit c4155c52 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #545

parents f3fb0d4c ffcccf3c
...@@ -26,6 +26,8 @@ use Iterator; ...@@ -26,6 +26,8 @@ use Iterator;
*/ */
class BSONIterator implements Iterator class BSONIterator implements Iterator
{ {
private static $bsonSize = 4;
private $buffer; private $buffer;
private $bufferLength; private $bufferLength;
private $current; private $current;
...@@ -33,8 +35,6 @@ class BSONIterator implements Iterator ...@@ -33,8 +35,6 @@ class BSONIterator implements Iterator
private $position = 0; private $position = 0;
private $options; private $options;
const BSON_SIZE = 4;
/** /**
* Constructs a BSON Iterator. * Constructs a BSON Iterator.
* *
...@@ -119,11 +119,11 @@ class BSONIterator implements Iterator ...@@ -119,11 +119,11 @@ class BSONIterator implements Iterator
return; return;
} }
if (($this->bufferLength - $this->position) < self::BSON_SIZE) { if (($this->bufferLength - $this->position) < self::$bsonSize) {
throw new UnexpectedValueException(sprintf('Expected at least %d bytes; %d remaining', self::BSON_SIZE, $this->bufferLength - $this->position)); throw new UnexpectedValueException(sprintf('Expected at least %d bytes; %d remaining', self::$bsonSize, $this->bufferLength - $this->position));
} }
list(,$documentLength) = unpack('V', substr($this->buffer, $this->position, self::BSON_SIZE)); list(,$documentLength) = unpack('V', substr($this->buffer, $this->position, self::$bsonSize));
if (($this->bufferLength - $this->position) < $documentLength) { if (($this->bufferLength - $this->position) < $documentLength) {
throw new UnexpectedValueException(sprintf('Expected %d bytes; %d remaining', $documentLength, $this->bufferLength - $this->position)); throw new UnexpectedValueException(sprintf('Expected %d bytes; %d remaining', $documentLength, $this->bufferLength - $this->position));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment