forked from DesignPatternsPHP/DesignPatternsPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Storage.php
42 lines (38 loc) · 906 Bytes
/
Storage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace DesignPatterns\More\Repository;
/**
* Interface Storage.
*
* This interface describes methods for accessing storage.
* Concrete realization could be whatever we want - in memory, relational database, NoSQL database and etc
*/
interface Storage
{
/**
* 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);
}