Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | namespace MediaWiki\WikispeechSpeechDataCollector\Crud; |
4 | |
5 | /** |
6 | * @file |
7 | * @ingroup Extensions |
8 | * @license GPL-2.0-or-later |
9 | */ |
10 | |
11 | use MediaWiki\WikispeechSpeechDataCollector\Domain\Persistent; |
12 | |
13 | /** |
14 | * Interface Crud |
15 | * |
16 | * Database access for |
17 | * instances of the corresponding underlying subclass of {@link Persistent}. |
18 | * |
19 | * @note Consider implementing Phan generics for hard typing subclass of Persistent. |
20 | * @since 0.1.0 |
21 | */ |
22 | interface Crud { |
23 | /** |
24 | * Given a persistent domain object instance with at least identity set, |
25 | * creates representation in database to correspond to the data set in the domain object. |
26 | * |
27 | * @param Persistent $instance Instance to be inserted to the persistent layer. |
28 | * @since 0.1.0 |
29 | */ |
30 | public function create( |
31 | Persistent $instance |
32 | ): void; |
33 | |
34 | /** |
35 | * Given an identity, |
36 | * retrieves a persistent domain object from the database. |
37 | * |
38 | * @see load() |
39 | * @param mixed $identity |
40 | * @return Persistent|null |
41 | * @since 0.1.0 |
42 | */ |
43 | public function read( |
44 | $identity |
45 | ): ?Persistent; |
46 | |
47 | /** |
48 | * Given a persistent domain object instance with at least identity set, |
49 | * updates the domain object to correspond data retrieved from the database. |
50 | * |
51 | * @see read() |
52 | * @param Persistent $instance Instance to be loaded. Identity must be set. |
53 | * @return bool true if found, false if not found. |
54 | * @since 0.1.0 |
55 | */ |
56 | public function load( |
57 | Persistent $instance |
58 | ): bool; |
59 | |
60 | /** |
61 | * Given a persistent domain object instance with at least identity set, |
62 | * updates the database to correspond to the data set in the domain object. |
63 | * |
64 | * @param Persistent $instance |
65 | * @since 0.1.0 |
66 | */ |
67 | public function update( |
68 | Persistent $instance |
69 | ): void; |
70 | |
71 | /** |
72 | * Given an identity, |
73 | * removes the corresponding persistent domain object from the database. |
74 | * |
75 | * @param mixed $identity |
76 | * @since 0.1.0 |
77 | */ |
78 | public function delete( |
79 | $identity |
80 | ): void; |
81 | } |