Repository pattern

This commit is contained in:
andrewnester
2014-03-12 13:11:49 +03:00
parent b0b0d4a1a4
commit a0c2a7d638
5 changed files with 304 additions and 0 deletions

41
Repository/IStorage.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
namespace DesignPatterns\Repository;
/**
* Interface IStorage
*
* This interface describes methods for accessing storage.
* Concrete realization could be whatever we want - in memory, relational database, NoSQL database and etc
*
* @package DesignPatterns\Repository
*/
interface IStorage
{
/**
* Method to persist data
* Returns new id for just persisted data
*
* @param array() $data
* @return int
*/
public function persist($data);
/**
* Returns data by specified id.
* If there is no such data null is returned
*
* @param int $id
* @return array|null
*/
public function retrieve($id);
/**
* Delete data specified by id
* If there is no such data - false returns, if data has been successfully deleted - true returns
*
* @param int $id
* @return bool
*/
public function delete($id);
}