-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathModelInterface.php
104 lines (90 loc) · 1.93 KB
/
ModelInterface.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
namespace Aternos\Model;
use Aternos\Model\Query\{Query, QueryResult};
/**
* Interface ModelInterface
*
* @package Aternos\Model\Driver
*/
interface ModelInterface
{
/**
* Get the name of the model used as table name etc.
*
* @return string
*/
public static function getName(): string;
/**
* Return the caching time for the model (in seconds)
*
* @return int
*/
public static function getCacheTime(): int;
/**
* Get the id of the model
*
* @return mixed
*/
public function getId(): mixed;
/**
* Set the id of the model
*
* @param string $id
* @return $this
*/
public function setId(mixed $id): static;
/**
* Get the name of the id field
*
* @return string
*/
public static function getIdField(): string;
/**
* Get a new model object from a raw data array
*
* @param array $rawData
* @return static|null
*/
public static function getModelFromData(array $rawData): ?static;
/**
* Get a model by id
*
* @param string $id
* @param bool $update
* @return static|bool
*/
public static function get(string $id, bool $update = false): ?static;
/**
* Query a model
*
* @param Query $query
* @return mixed
*/
public static function query(Query $query): QueryResult;
/**
* Save a model
*
* @return bool
*/
public function save(): bool;
/**
* Delete a model
*
* @return bool
*/
public function delete(): bool;
/**
* Get a field value, even if it's not part of the defined model
*
* @param string $key
* @return mixed
*/
public function getField(string $key): mixed;
/**
* Apply data to the model
*
* @param array $rawData
* @return $this
*/
public function applyData(array $rawData): static;
}