Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
75.00% |
18 / 24 |
|
62.50% |
10 / 16 |
CRAP | |
0.00% |
0 / 1 |
CrudTransactionRequest | |
75.00% |
18 / 24 |
|
62.50% |
10 / 16 |
26.25 | |
0.00% |
0 / 1 |
addCreate | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
addRead | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
addUpdate | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
addDelete | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
getReference | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setReference | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCreate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setCreate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRead | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRead | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUpdate | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setUpdate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getDelete | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setDelete | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
isReadGraph | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setReadGraph | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\WikispeechSpeechDataCollector\Crud\Transaction; |
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 | * @todo This is part of an internal development API. It should be removed before deployment. |
15 | * |
16 | * A collection of {@link Persistent} objects that will be sent |
17 | * either to creation, to be read, to be updated or to be deleted |
18 | * via {@link CrudTransactionExecutor}. |
19 | * |
20 | * @since 0.1.0 |
21 | */ |
22 | class CrudTransactionRequest { |
23 | |
24 | /** |
25 | * @var mixed|null Client reference, passed back in response. |
26 | * @see CrudTransactionResponse::$reference |
27 | */ |
28 | private $reference; |
29 | |
30 | /** @var array|null {@link Persistent} instances */ |
31 | private $create; |
32 | |
33 | /** @var array|null {@link Persistent} instances */ |
34 | private $read; |
35 | |
36 | /** @var array|null {@link Persistent} instances */ |
37 | private $update; |
38 | |
39 | /** @var array|null {@link Persistent} instances */ |
40 | private $delete; |
41 | |
42 | /** @var bool Whether to load predefined object graphs or just the single requested object. */ |
43 | private $readGraph = false; |
44 | |
45 | // Add-helpers |
46 | |
47 | /** @param Persistent $instance */ |
48 | public function addCreate( Persistent $instance ) { |
49 | if ( $this->create === null ) { |
50 | $this->create = []; |
51 | } |
52 | $this->create[] = $instance; |
53 | } |
54 | |
55 | /** @param Persistent $instance */ |
56 | public function addRead( Persistent $instance ) { |
57 | if ( $this->read === null ) { |
58 | $this->read = []; |
59 | } |
60 | $this->read[] = $instance; |
61 | } |
62 | |
63 | /** @param Persistent $instance */ |
64 | public function addUpdate( Persistent $instance ) { |
65 | if ( $this->update === null ) { |
66 | $this->update = []; |
67 | } |
68 | $this->update[] = $instance; |
69 | } |
70 | |
71 | /** @param Persistent $instance */ |
72 | public function addDelete( Persistent $instance ) { |
73 | if ( $this->delete === null ) { |
74 | $this->delete = []; |
75 | } |
76 | $this->delete[] = $instance; |
77 | } |
78 | |
79 | // Getters and setters |
80 | |
81 | /** |
82 | * @return mixed|null |
83 | */ |
84 | public function getReference() { |
85 | return $this->reference; |
86 | } |
87 | |
88 | /** |
89 | * @param mixed|null $reference |
90 | */ |
91 | public function setReference( $reference ): void { |
92 | $this->reference = $reference; |
93 | } |
94 | |
95 | /** |
96 | * @return array|null |
97 | */ |
98 | public function getCreate(): ?array { |
99 | return $this->create; |
100 | } |
101 | |
102 | /** |
103 | * @param array|null $create |
104 | */ |
105 | public function setCreate( ?array $create ): void { |
106 | $this->create = $create; |
107 | } |
108 | |
109 | /** |
110 | * @return array|null |
111 | */ |
112 | public function getRead(): ?array { |
113 | return $this->read; |
114 | } |
115 | |
116 | /** |
117 | * @param array|null $read |
118 | */ |
119 | public function setRead( ?array $read ): void { |
120 | $this->read = $read; |
121 | } |
122 | |
123 | /** |
124 | * @return array|null |
125 | */ |
126 | public function getUpdate(): ?array { |
127 | return $this->update; |
128 | } |
129 | |
130 | /** |
131 | * @param array|null $update |
132 | */ |
133 | public function setUpdate( ?array $update ): void { |
134 | $this->update = $update; |
135 | } |
136 | |
137 | /** |
138 | * @return array|null |
139 | */ |
140 | public function getDelete(): ?array { |
141 | return $this->delete; |
142 | } |
143 | |
144 | /** |
145 | * @param array|null $delete |
146 | */ |
147 | public function setDelete( ?array $delete ): void { |
148 | $this->delete = $delete; |
149 | } |
150 | |
151 | /** |
152 | * @return bool |
153 | */ |
154 | public function isReadGraph(): bool { |
155 | return $this->readGraph; |
156 | } |
157 | |
158 | /** |
159 | * @param bool $readGraph |
160 | */ |
161 | public function setReadGraph( bool $readGraph ): void { |
162 | $this->readGraph = $readGraph; |
163 | } |
164 | |
165 | } |