mirror of
https://github.com/predis/predis.git
synced 2026-08-22 14:31:12 +00:00
4e6ed3f26d
This is a starting point to add a documentation of the whole set of APIs and classes of Predis. The next step will be to actually improve and extend it.
58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Predis package.
|
|
*
|
|
* (c) Daniele Alessandri <suppakilla@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Predis\Iterators;
|
|
|
|
/**
|
|
* Abstract the access to a streamable list of tuples represented
|
|
* as a multibulk reply that alternates keys and values.
|
|
*
|
|
* @author Daniele Alessandri <suppakilla@gmail.com>
|
|
*/
|
|
class MultiBulkResponseTuple extends MultiBulkResponse
|
|
{
|
|
private $_iterator;
|
|
|
|
/**
|
|
* @param MultiBulkResponseSimple $iterator Multibulk reply iterator.
|
|
*/
|
|
public function __construct(MultiBulkResponseSimple $iterator)
|
|
{
|
|
$virtualSize = count($iterator) / 2;
|
|
$this->_iterator = $iterator;
|
|
$this->_position = 0;
|
|
$this->_current = $virtualSize > 0 ? $this->getValue() : null;
|
|
$this->_replySize = $virtualSize;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function __destruct()
|
|
{
|
|
$this->_iterator->sync();
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function getValue()
|
|
{
|
|
$k = $this->_iterator->current();
|
|
$this->_iterator->next();
|
|
|
|
$v = $this->_iterator->current();
|
|
$this->_iterator->next();
|
|
|
|
return array($k, $v);
|
|
}
|
|
}
|