mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-02 13:07:27 +02:00
Repository pattern - some code style changes
This commit is contained in:
@@ -6,7 +6,7 @@ namespace DesignPatterns\Repository;
|
|||||||
* Class MemoryStorage
|
* Class MemoryStorage
|
||||||
* @package DesignPatterns\Repository
|
* @package DesignPatterns\Repository
|
||||||
*/
|
*/
|
||||||
class MemoryStorage implements IStorage
|
class MemoryStorage implements Storage
|
||||||
{
|
{
|
||||||
|
|
||||||
private $data;
|
private $data;
|
||||||
|
@@ -4,7 +4,7 @@ namespace DesignPatterns\Repository;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository for class Post
|
* Repository for class Post
|
||||||
* This class is between Entity layer(class Post) and access object layer(interface IStorage)
|
* This class is between Entity layer(class Post) and access object layer(interface Storage)
|
||||||
* Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer
|
* Repository encapsulates the set of objects persisted in a data store and the operations performed over them, providing a more object-oriented view of the persistence layer
|
||||||
* Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers
|
* Repository also supports the objective of achieving a clean separation and one-way dependency between the domain and data mapping layers
|
||||||
*
|
*
|
||||||
@@ -15,7 +15,7 @@ class PostRepository
|
|||||||
{
|
{
|
||||||
private $persistence;
|
private $persistence;
|
||||||
|
|
||||||
public function __construct(IStorage $persistence)
|
public function __construct(Storage $persistence)
|
||||||
{
|
{
|
||||||
$this->persistence = $persistence;
|
$this->persistence = $persistence;
|
||||||
}
|
}
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
namespace DesignPatterns\Repository;
|
namespace DesignPatterns\Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface IStorage
|
* Interface Storage
|
||||||
*
|
*
|
||||||
* This interface describes methods for accessing storage.
|
* This interface describes methods for accessing storage.
|
||||||
* Concrete realization could be whatever we want - in memory, relational database, NoSQL database and etc
|
* Concrete realization could be whatever we want - in memory, relational database, NoSQL database and etc
|
||||||
*
|
*
|
||||||
* @package DesignPatterns\Repository
|
* @package DesignPatterns\Repository
|
||||||
*/
|
*/
|
||||||
interface IStorage
|
interface Storage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Method to persist data
|
* Method to persist data
|
Reference in New Issue
Block a user