-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepositoryInterface.php
More file actions
63 lines (55 loc) · 1.99 KB
/
RepositoryInterface.php
File metadata and controls
63 lines (55 loc) · 1.99 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Guillermoandrae\Repositories;
use Guillermoandrae\Common\CollectionInterface;
use Guillermoandrae\Models\ModelInterface;
interface RepositoryInterface
{
/**
* Returns the model with the provided primary key.
*
* @param mixed $primaryKey The primary key of the desired model.
* @return ModelInterface|null
*/
public function find(mixed $primaryKey): ?ModelInterface;
/**
* Returns a collection of models within the provided range.
*
* @param int $offset The desired offset.
* @param int|null $limit The desired limit.
* @return CollectionInterface|null
*/
public function findAll(int $offset = 0, ?int $limit = null): ?CollectionInterface;
/**
* Returns a collection of models that meet the provided criteria within
* the provided range.
*
* @param array $where The selection criteria.
* @param int $offset The desired offset.
* @param int|null $limit The desired limit.
* @return CollectionInterface|null
*/
public function findWhere(array $where, int $offset = 0, ?int $limit = null): ?CollectionInterface;
/**
* Creates a model using the provided data and returns that model.
*
* @param array $data The data to use when creating the model.
* @return ModelInterface|null
*/
public function create(array $data): ?ModelInterface;
/**
* Updates the model associated with the provided primary key using the
* provided data. Returns the updated model.
*
* @param mixed $primaryKey The primary key of the desired model.
* @param array $data The data to use when updating the model.
* @return ModelInterface|null
*/
public function update(mixed $primaryKey, array $data): ?ModelInterface;
/**
* Deletes the model associated with the provided primary key.
*
* @param mixed $primaryKey The ID of the desired model.
* @return bool
*/
public function delete(mixed $primaryKey): bool;
}