forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doctrine#6167 - code cleanup for 2.5.x version
- Loading branch information
Alexey Snigirev
committed
Nov 27, 2017
1 parent
a857a61
commit a23e909
Showing
3 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?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($fetchMode = null, $fetchArgument = null, $ctorArgs = null) | ||
{ | ||
return $this->_result; | ||
} | ||
|
||
public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) | ||
{ | ||
$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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters