Add classes and tests from common project
This commit is contained in:
36
src/DocumentList.php
Normal file
36
src/DocumentList.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument;
|
||||
|
||||
use Generator;
|
||||
|
||||
/**
|
||||
* A lazy iterator of results in a list; implementations will create new connections to the database and close/dispose
|
||||
* them as required once the results have been exhausted.
|
||||
*
|
||||
* @template TDoc The domain class for items returned by this list
|
||||
*/
|
||||
interface DocumentList
|
||||
{
|
||||
/**
|
||||
* The items from the query result
|
||||
*
|
||||
* @return Generator<TDoc> The query results as a lazily-iterated generator
|
||||
*/
|
||||
public function items(): Generator;
|
||||
|
||||
/**
|
||||
* Construct a new document list
|
||||
*
|
||||
* @param string $query The query to run to retrieve results
|
||||
* @param array $parameters An associative array of parameters for the query
|
||||
* @param Mapper<TDoc> $mapper A mapper to deserialize JSON documents
|
||||
* @return static The `DocumentList`-implementing instance
|
||||
*/
|
||||
public static function create(string $query, array $parameters, Mapper $mapper): static;
|
||||
|
||||
/**
|
||||
* Clean up database connection resources
|
||||
*/
|
||||
public function __destruct();
|
||||
}
|
||||
Reference in New Issue
Block a user