mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-03 13:37:27 +02:00
introduced Storage interface
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace DesignPatterns\More\Repository;
|
||||
|
||||
class MemoryStorage
|
||||
class MemoryStorage implements Storage
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
|
@@ -14,11 +14,11 @@ namespace DesignPatterns\More\Repository;
|
||||
class PostRepository
|
||||
{
|
||||
/**
|
||||
* @var MemoryStorage
|
||||
* @var Storage
|
||||
*/
|
||||
private $persistence;
|
||||
|
||||
public function __construct(MemoryStorage $persistence)
|
||||
public function __construct(Storage $persistence)
|
||||
{
|
||||
$this->persistence = $persistence;
|
||||
}
|
||||
|
12
More/Repository/Storage.php
Normal file
12
More/Repository/Storage.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace DesignPatterns\More\Repository;
|
||||
|
||||
interface Storage
|
||||
{
|
||||
public function persist(array $data): int;
|
||||
|
||||
public function retrieve(int $id): array;
|
||||
|
||||
public function delete(int $id);
|
||||
}
|
Reference in New Issue
Block a user