1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace Predis\Iterators;
- class MultiBulkResponseTuple extends MultiBulkResponse implements \OuterIterator
- {
- private $iterator;
-
- public function __construct(MultiBulkResponseSimple $iterator)
- {
- $virtualSize = count($iterator) / 2;
- $this->iterator = $iterator;
- $this->position = $iterator->getPosition();
- $this->current = $virtualSize > 0 ? $this->getValue() : null;
- $this->replySize = $virtualSize;
- }
-
- public function getInnerIterator()
- {
- return $this->iterator;
- }
-
- public function __destruct()
- {
- $this->iterator->sync(true);
- }
-
- protected function getValue()
- {
- $k = $this->iterator->current();
- $this->iterator->next();
- $v = $this->iterator->current();
- $this->iterator->next();
- return array($k, $v);
- }
- }
|