Skip to content

Commit ffcccf3

Browse files
authored
Use private static member for internal constant
1 parent f3fb0d4 commit ffcccf3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Model/BSONIterator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*/
2727
class BSONIterator implements Iterator
2828
{
29+
private static $bsonSize = 4;
30+
2931
private $buffer;
3032
private $bufferLength;
3133
private $current;
3234
private $key = 0;
3335
private $position = 0;
3436
private $options;
3537

36-
const BSON_SIZE = 4;
37-
3838
/**
3939
* Constructs a BSON Iterator.
4040
*
@@ -119,11 +119,11 @@ private function advance()
119119
return;
120120
}
121121

122-
if (($this->bufferLength - $this->position) < self::BSON_SIZE) {
123-
throw new UnexpectedValueException(sprintf('Expected at least %d bytes; %d remaining', self::BSON_SIZE, $this->bufferLength - $this->position));
122+
if (($this->bufferLength - $this->position) < self::$bsonSize) {
123+
throw new UnexpectedValueException(sprintf('Expected at least %d bytes; %d remaining', self::$bsonSize, $this->bufferLength - $this->position));
124124
}
125125

126-
list(,$documentLength) = unpack('V', substr($this->buffer, $this->position, self::BSON_SIZE));
126+
list(,$documentLength) = unpack('V', substr($this->buffer, $this->position, self::$bsonSize));
127127

128128
if (($this->bufferLength - $this->position) < $documentLength) {
129129
throw new UnexpectedValueException(sprintf('Expected %d bytes; %d remaining', $documentLength, $this->bufferLength - $this->position));

0 commit comments

Comments
 (0)