for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Cassandra\Response;
/**
* @author Dennis Birkholz <[email protected]>
*/
class ResultIterator implements \Iterator {
* Stream containing the raw result data
*
* @var StreamReader
private $stream;
* Offset to start reading data in this stream
* @var int
private $offset;
* Metadata generated by the creating Result
* @var array
private $metadata;
* Class to use for each row of data
* @var string
private $rowClass;
* Number of available rows in the resultset
private $count;
* Current row
private $row = 0;
public function __construct(StreamReader $stream, array $metadata, $rowClass) {
$rowClass
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$this->stream = clone $stream;
$this->metadata = $metadata;
$this->count = $this->stream->readInt();
$this->offset = $this->stream->pos();
$this->rewind();
}
public function current() {
$data = [];
foreach ($this->metadata['columns'] as $column) {
$data[$column['name']] = $this->stream->readValue($column['type']);
$rowClass = $this->rowClass;
return ($rowClass === null ? $data : new $rowClass($data));
* The current position in this result set
* @return int
public function key() {
return $this->row;
* Move forward to next element
* @return void
public function next() {
$this->row++;
* Reset the result set
public function rewind() {
$this->row = 0;
$this->stream->offset($this->offset);
* Checks if current position is valid
* @return boolean
public function valid() {
return (($this->row >= 0) && ($this->row < $this->count));
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.