CrudInterface
last analyzed

Size/Duplication

Total Lines 246
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 246
c 0
b 0
f 0

32 Methods

Rating   Name   Duplication   Size   Complexity  
combineWithAnd() 0 1 ?
combineWithOr() 0 1 ?
withFilters() 0 1 ?
withIndexFilter() 0 1 ?
withIndexesFilter() 0 1 ?
withSorts() 0 1 ?
withIncludes() 0 1 ?
withPaging() 0 1 ?
withoutPaging() 0 1 ?
withRelationshipFilters() 0 1 ?
withRelationshipSorts() 0 1 ?
createIndexBuilder() 0 1 ?
createDeleteBuilder() 0 1 ?
fetchResources() 0 1 ?
fetchResource() 0 1 ?
fetchRow() 0 1 ?
fetchColumn() 0 1 ?
index() 0 1 ?
indexIdentities() 0 1 ?
read() 0 1 ?
count() 0 1 ?
delete() 0 1 ?
remove() 0 1 ?
create() 0 1 ?
update() 0 1 ?
indexRelationship() 0 5 ?
indexRelationshipIdentities() 0 5 ?
readRelationship() 0 6 ?
hasInRelationship() 0 1 ?
createInBelongsToManyRelationship() 0 1 ?
removeInBelongsToManyRelationship() 0 1 ?
inTransaction() 0 1 ?
1
<?php declare (strict_types = 1);
2
3
namespace Limoncello\Flute\Contracts\Api;
4
5
/**
6
 * Copyright 2015-2019 [email protected]
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 * http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20
21
use Closure;
22
use Doctrine\DBAL\Query\QueryBuilder;
23
use Limoncello\Flute\Contracts\Models\PaginatedDataInterface;
24
25
/**
26
 * @package Limoncello\Flute
27
 */
28
interface CrudInterface
29
{
30
    /**
31
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
32
     */
33
    public function combineWithAnd(): self;
34
35
    /**
36
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
37
     */
38
    public function combineWithOr(): self;
39
40
    /**
41
     * @param iterable $filterParameters
42
     *
43
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
44
     */
45
    public function withFilters(iterable $filterParameters): self;
46
47
    /**
48
     * @param string $index
49
     *
50
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
51
     */
52
    public function withIndexFilter(string $index): self;
53
54
    /**
55
     * @param array $indexes
56
     *
57
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
58
     */
59
    public function withIndexesFilter(array $indexes): self;
60
61
    /**
62
     * @param iterable $sortingParameters
63
     *
64
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
65
     */
66
    public function withSorts(iterable $sortingParameters): self;
67
68
    /**
69
     * @param iterable $includePaths
70
     *
71
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
72
     */
73
    public function withIncludes(iterable $includePaths): self;
74
75
    /**
76
     * @param int $offset
77
     * @param int $limit
78
     *
79
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
80
     */
81
    public function withPaging(int $offset, int $limit): self;
82
83
    /**
84
     * @return self
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
85
     */
86
    public function withoutPaging(): self;
87
88
    /**
89
     * @param string   $name
90
     * @param iterable $filters
91
     *
92
     * @return CrudInterface
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
93
     */
94
    public function withRelationshipFilters(string $name, iterable $filters): self;
95
96
    /**
97
     * @param string   $name
98
     * @param iterable $sorts
99
     *
100
     * @return CrudInterface
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
101
     */
102
    public function withRelationshipSorts(string $name, iterable $sorts): self;
103
104
    /**
105
     * @param iterable|null $columns
106
     *
107
     * @return QueryBuilder
108
     */
109
    public function createIndexBuilder(iterable $columns = null): QueryBuilder;
110
111
    /**
112
     * @return QueryBuilder
113
     */
114
    public function createDeleteBuilder(): QueryBuilder;
115
116
    /**
117
     * @param QueryBuilder $builder
118
     * @param string       $modelClass
119
     *
120
     * @return PaginatedDataInterface
121
     */
122
    public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface;
123
124
    /**
125
     * @param QueryBuilder|null $builder
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $builder a bit more specific; maybe use QueryBuilder.
Loading history...
126
     * @param string|null       $modelClass
127
     *
128
     * @return mixed|null
129
     */
130
    public function fetchResource(QueryBuilder $builder, string $modelClass);
131
132
    /**
133
     * @param QueryBuilder $builder
134
     * @param string       $modelClass
135
     *
136
     * @return array|null
137
     */
138
    public function fetchRow(QueryBuilder $builder, string $modelClass): ?array;
139
140
    /**
141
     * @param QueryBuilder $builder
142
     * @param string       $modelClass
143
     * @param string       $columnName
144
     *
145
     * @return iterable
146
     */
147
    public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable;
148
149
    /**
150
     * @return PaginatedDataInterface
151
     */
152
    public function index(): PaginatedDataInterface;
153
154
    /**
155
     * @return array
156
     */
157
    public function indexIdentities(): array;
158
159
    /**
160
     * @param string $index
161
     *
162
     * @return mixed|null
163
     */
164
    public function read(string $index);
165
166
    /**
167
     * @return int|null
168
     */
169
    public function count(): ?int;
170
171
    /**
172
     * @return int
173
     */
174
    public function delete(): int;
175
176
    /**
177
     * @param string $index
178
     *
179
     * @return bool
180
     */
181
    public function remove(string $index): bool;
182
183
    /**
184
     * @param null|string $index
185
     * @param array       $attributes
186
     * @param array       $toMany
187
     *
188
     * @return string
189
     */
190
    public function create(?string $index, array $attributes, array $toMany): string;
191
192
    /**
193
     * @param string $index
194
     * @param array  $attributes
195
     * @param array  $toMany
196
     *
197
     * @return int
198
     */
199
    public function update(string $index, array $attributes, array $toMany): int;
200
201
    /**
202
     * @param string        $name
203
     * @param iterable|null $relationshipFilters
204
     * @param iterable|null $relationshipSorts
205
     *
206
     * @return PaginatedDataInterface|mixed|null
207
     */
208
    public function indexRelationship(
209
        string $name,
210
        iterable $relationshipFilters = null,
211
        iterable $relationshipSorts = null
212
    );
213
214
    /**
215
     * @param string        $name
216
     * @param iterable|null $relationshipFilters
217
     * @param iterable|null $relationshipSorts
218
     *
219
     * @return array
220
     */
221
    public function indexRelationshipIdentities(
222
        string $name,
223
        iterable $relationshipFilters = null,
224
        iterable $relationshipSorts = null
225
    ): array;
226
227
    /**
228
     * @param string        $index
229
     * @param string        $name
230
     * @param iterable|null $relationshipFilters
231
     * @param iterable|null $relationshipSorts
232
     *
233
     * @return PaginatedDataInterface|mixed|null
234
     */
235
    public function readRelationship(
236
        string $index,
237
        string $name,
238
        iterable $relationshipFilters = null,
239
        iterable $relationshipSorts = null
240
    );
241
242
    /**
243
     * @param string $parentId
244
     * @param string $name
245
     * @param string $childId
246
     *
247
     * @return bool
248
     */
249
    public function hasInRelationship(string $parentId, string $name, string $childId): bool;
250
251
    /**
252
     * @param string   $parentId
253
     * @param string   $name
254
     * @param iterable $childIds
255
     *
256
     * @return int
257
     */
258
    public function createInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int;
259
260
    /**
261
     * @param string   $parentId
262
     * @param string   $name
263
     * @param iterable $childIds
264
     *
265
     * @return int
266
     */
267
    public function removeInBelongsToManyRelationship(string $parentId, string $name, iterable $childIds): int;
268
269
    /**
270
     * @param Closure $closure
271
     */
272
    public function inTransaction(Closure $closure): void;
273
}
274