1
0
mirror of synced 2025-02-02 21:41:45 +03:00
doctrine2/tests/Doctrine/Tests/Mocks/StatementArrayMock.php
2016-10-26 13:24:33 -03:00

66 lines
1.2 KiB
PHP

<?php
namespace Doctrine\Tests\Mocks;
/**
* Simple statement mock that returns result based on array.
* Doesn't support fetch modes
*/
class StatementArrayMock extends StatementMock
{
/**
* @var array
*/
private $_result;
public function __construct($result)
{
$this->_result = $result;
}
public function getIterator()
{
return new \ArrayIterator($this->_result);
}
public function columnCount()
{
$row = reset($this->_result);
if ($row) {
return count($row);
} else {
return 0;
}
}
public function fetchAll($fetchStyle = null)
{
return $this->_result;
}
public function fetch($fetchStyle = null)
{
$current = current($this->_result);
next($this->_result);
return $current;
}
public function fetchColumn($columnIndex = 0)
{
$current = current($this->_result);
if ($current) {
next($this->_result);
return reset($current);
} else {
return false;
}
}
public function rowCount()
{
return count($this->_result);
}
}