RepositoryContract
last analyzed

Size/Duplication

Total Lines 467
Duplicated Lines 0 %

Importance

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

48 Methods

Rating   Name   Duplication   Size   Complexity  
create() 0 1 ?
setContainer() 0 1 ?
getContainer() 0 1 ?
setConnection() 0 1 ?
getConnection() 0 1 ?
setRepositoryId() 0 1 ?
getRepositoryId() 0 1 ?
setModel() 0 1 ?
getModel() 0 1 ?
createModel() 0 1 ?
with() 0 1 ?
where() 0 1 ?
whereIn() 0 1 ?
whereNotIn() 0 1 ?
whereHas() 0 1 ?
scope() 0 1 ?
offset() 0 1 ?
limit() 0 1 ?
orderBy() 0 1 ?
groupBy() 0 1 ?
having() 0 1 ?
orHaving() 0 1 ?
find() 0 1 ?
findOrFail() 0 1 ?
findOrNew() 0 1 ?
findBy() 0 1 ?
findFirst() 0 1 ?
findAll() 0 1 ?
paginate() 0 1 ?
simplePaginate() 0 1 ?
findWhere() 0 1 ?
findWhereIn() 0 1 ?
findWhereNotIn() 0 1 ?
findWhereHas() 0 1 ?
update() 0 1 ?
store() 0 1 ?
delete() 0 1 ?
restore() 0 1 ?
beginTransaction() 0 1 ?
commit() 0 1 ?
rollBack() 0 1 ?
count() 0 1 ?
min() 0 1 ?
max() 0 1 ?
avg() 0 1 ?
sum() 0 1 ?
__callStatic() 0 1 ?
__call() 0 1 ?
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Repository\Contracts;
6
7
use Closure;
8
use Illuminate\Contracts\Container\Container;
9
10
interface RepositoryContract
11
{
12
    /**
13
     * Set the IoC container instance.
14
     *
15
     * @param \Illuminate\Contracts\Container\Container $container
16
     *
17
     * @return static
18
     */
19
    public function setContainer(Container $container);
20
21
    /**
22
     * Get the IoC container instance or any of its services.
23
     *
24
     * @param string|null $service
25
     *
26
     * @return mixed
27
     */
28
    public function getContainer($service = null);
29
30
    /**
31
     * Set the connection associated with the repository.
32
     *
33
     * @param string $name
34
     *
35
     * @return static
36
     */
37
    public function setConnection($name);
38
39
    /**
40
     * Get the current connection for the repository.
41
     *
42
     * @return string
43
     */
44
    public function getConnection(): string;
45
46
    /**
47
     * Set the repository identifier.
48
     *
49
     * @param string $repositoryId
50
     *
51
     * @return static
52
     */
53
    public function setRepositoryId($repositoryId);
54
55
    /**
56
     * Get the repository identifier.
57
     *
58
     * @return string
59
     */
60
    public function getRepositoryId(): string;
61
62
    /**
63
     * Set the repository model.
64
     *
65
     * @param string $model
66
     *
67
     * @return static
68
     */
69
    public function setModel($model);
70
71
    /**
72
     * Get the repository model.
73
     *
74
     * @return string
75
     */
76
    public function getModel(): string;
77
78
    /**
79
     * Create a new repository model instance.
80
     *
81
     * @throws \Rinvex\Repository\Exceptions\RepositoryException
82
     *
83
     * @return mixed
84
     */
85
    public function createModel();
86
87
    /**
88
     * Set the relationships that should be eager loaded.
89
     *
90
     * @param array|string $relations
91
     *
92
     * @return static
93
     */
94
    public function with($relations);
95
96
    /**
97
     * Add a basic where clause to the query.
98
     *
99
     * @param string $attribute
100
     * @param string $operator
101
     * @param mixed  $value
102
     * @param string $boolean
103
     *
104
     * @return static
105
     */
106
    public function where($attribute, $operator = null, $value = null, $boolean = 'and');
107
108
    /**
109
     * Add a "where in" clause to the query.
110
     *
111
     * @param string $attribute
112
     * @param mixed  $values
113
     * @param string $boolean
114
     * @param bool   $not
115
     *
116
     * @return static
117
     */
118
    public function whereIn($attribute, $values, $boolean = 'and', $not = false);
119
120
    /**
121
     * Add a "where not in" clause to the query.
122
     *
123
     * @param string $attribute
124
     * @param mixed  $values
125
     * @param string $boolean
126
     *
127
     * @return static
128
     */
129
    public function whereNotIn($attribute, $values, $boolean = 'and');
130
131
    /**
132
     * Add a "where has relationship" clause to the query.
133
     *
134
     * @param string   $relation
135
     * @param \Closure $callback
0 ignored issues
show
Documentation introduced by
Should the type for parameter $callback not be null|Closure?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
136
     * @param string   $operator
137
     * @param int      $count
138
     *
139
     * @return static
140
     */
141
    public function whereHas($relation, Closure $callback = null, $operator = '>=', $count = 1);
142
143
    /**
144
     * Add a scope to the query.
145
     *
146
     * @param string $name
147
     * @param array  $parameters
148
     *
149
     * @return static
150
     */
151
    public function scope($name, array $parameters = []);
152
153
    /**
154
     * Set the "offset" value of the query.
155
     *
156
     * @param int $offset
157
     *
158
     * @return static
159
     */
160
    public function offset($offset);
161
162
    /**
163
     * Set the "limit" value of the query.
164
     *
165
     * @param int $limit
166
     *
167
     * @return static
168
     */
169
    public function limit($limit);
170
171
    /**
172
     * Add an "order by" clause to the query.
173
     *
174
     * @param string $attribute
175
     * @param string $direction
176
     *
177
     * @return static
178
     */
179
    public function orderBy($attribute, $direction = 'asc');
180
181
    /**
182
     * Add a "group by" clause to the query.
183
     *
184
     * @param array|string $column
185
     *
186
     * @return static
187
     */
188
    public function groupBy($column);
189
190
    /**
191
     * Add a "having" clause to the query.
192
     *
193
     * @param string $column
194
     * @param string $operator
0 ignored issues
show
Documentation introduced by
Should the type for parameter $operator not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
195
     * @param string $value
0 ignored issues
show
Documentation introduced by
Should the type for parameter $value not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
196
     * @param string $boolean
197
     *
198
     * @return static
199
     */
200
    public function having($column, $operator = null, $value = null, $boolean = 'and');
201
202
    /**
203
     * Add a "or having" clause to the query.
204
     *
205
     * @param string $column
206
     * @param string $operator
0 ignored issues
show
Documentation introduced by
Should the type for parameter $operator not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
207
     * @param string $value
0 ignored issues
show
Documentation introduced by
Should the type for parameter $value not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
208
     *
209
     * @return static
210
     */
211
    public function orHaving($column, $operator = null, $value = null);
212
213
    /**
214
     * Find an entity by its primary key.
215
     *
216
     * @param int   $id
217
     * @param array $attributes
218
     *
219
     * @return mixed
220
     */
221
    public function find($id, $attributes = ['*']);
222
223
    /**
224
     * Find an entity by its primary key or throw an exception.
225
     *
226
     * @param mixed $id
227
     * @param array $attributes
228
     *
229
     * @throws \RuntimeException
230
     *
231
     * @return mixed
232
     */
233
    public function findOrFail($id, $attributes = ['*']);
234
235
    /**
236
     * Find an entity by its primary key or return fresh entity instance.
237
     *
238
     * @param mixed $id
239
     * @param array $attributes
240
     *
241
     * @return mixed
242
     */
243
    public function findOrNew($id, $attributes = ['*']);
244
245
    /**
246
     * Find an entity by one of its attributes.
247
     *
248
     * @param string $attribute
249
     * @param string $value
250
     * @param array  $attributes
251
     *
252
     * @return mixed
253
     */
254
    public function findBy($attribute, $value, $attributes = ['*']);
255
256
    /**
257
     * Find the first entity.
258
     *
259
     * @param array $attributes
260
     *
261
     * @return mixed
262
     */
263
    public function findFirst($attributes = ['*']);
264
265
    /**
266
     * Find all entities.
267
     *
268
     * @param array $attributes
269
     *
270
     * @return \Illuminate\Support\Collection
271
     */
272
    public function findAll($attributes = ['*']);
273
274
    /**
275
     * Paginate all entities.
276
     *
277
     * @param int|null $perPage
278
     * @param array    $attributes
279
     * @param string   $pageName
280
     * @param int|null $page
281
     *
282
     * @throws \InvalidArgumentException
283
     *
284
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
285
     */
286
    public function paginate($perPage = null, $attributes = ['*'], $pageName = 'page', $page = null);
287
288
    /**
289
     * Paginate all entities into a simple paginator.
290
     *
291
     * @param int|null $perPage
292
     * @param array    $attributes
293
     * @param string   $pageName
294
     *
295
     * @return \Illuminate\Contracts\Pagination\Paginator
296
     */
297
    public function simplePaginate($perPage = null, $attributes = ['*'], $pageName = 'page');
298
299
    /**
300
     * Find all entities matching where conditions.
301
     *
302
     * @param array $where
303
     * @param array $attributes
304
     *
305
     * @return \Illuminate\Support\Collection
306
     */
307
    public function findWhere(array $where, $attributes = ['*']);
308
309
    /**
310
     * Find all entities matching whereIn conditions.
311
     *
312
     * @param array $where
313
     * @param array $attributes
314
     *
315
     * @return \Illuminate\Support\Collection
316
     */
317
    public function findWhereIn(array $where, $attributes = ['*']);
318
319
    /**
320
     * Find all entities matching whereNotIn conditions.
321
     *
322
     * @param array $where
323
     * @param array $attributes
324
     *
325
     * @return \Illuminate\Support\Collection
326
     */
327
    public function findWhereNotIn(array $where, $attributes = ['*']);
328
329
    /**
330
     * Find all entities matching whereHas conditions.
331
     *
332
     * @param array $where
333
     * @param array $attributes
334
     *
335
     * @return \Illuminate\Support\Collection
336
     */
337
    public function findWhereHas(array $where, $attributes = ['*']);
338
339
    /**
340
     * Create a new entity with the given attributes.
341
     *
342
     * @param array $attributes
343
     * @param bool  $syncRelations
344
     *
345
     * @return mixed
346
     */
347
    public function create(array $attributes = [], bool $syncRelations = false);
348
349
    /**
350
     * Update an entity with the given attributes.
351
     *
352
     * @param mixed $id
353
     * @param array $attributes
354
     * @param bool  $syncRelations
355
     *
356
     * @return mixed
357
     */
358
    public function update($id, array $attributes = [], bool $syncRelations = false);
359
360
    /**
361
     * Store the entity with the given attributes.
362
     *
363
     * @param mixed $id
364
     * @param array $attributes
365
     * @param bool  $syncRelations
366
     *
367
     * @return mixed
368
     */
369
    public function store($id, array $attributes = [], bool $syncRelations = false);
370
371
    /**
372
     * Delete an entity with the given id.
373
     *
374
     * @param mixed $id
375
     *
376
     * @return mixed
377
     */
378
    public function delete($id);
379
380
    /**
381
     * Restore an entity with the given id.
382
     *
383
     * @param mixed $id
384
     *
385
     * @return mixed
386
     */
387
    public function restore($id);
388
389
    /**
390
     * Start a new database transaction.
391
     *
392
     * @throws \Exception
393
     *
394
     * @return void
395
     */
396
    public function beginTransaction(): void;
397
398
    /**
399
     * Commit the active database transaction.
400
     *
401
     * @return void
402
     */
403
    public function commit(): void;
404
405
    /**
406
     * Rollback the active database transaction.
407
     *
408
     * @return void
409
     */
410
    public function rollBack(): void;
411
412
    /**
413
     * Retrieve the "count" result of the query.
414
     *
415
     * @param string $columns
416
     *
417
     * @return int
418
     */
419
    public function count($columns = '*'): int;
420
421
    /**
422
     * Retrieve the minimum value of a given column.
423
     *
424
     * @param string $column
425
     *
426
     * @return mixed
427
     */
428
    public function min($column);
429
430
    /**
431
     * Retrieve the maximum value of a given column.
432
     *
433
     * @param string $column
434
     *
435
     * @return mixed
436
     */
437
    public function max($column);
438
439
    /**
440
     * Retrieve the average value of a given column.
441
     *
442
     * @param string $column
443
     *
444
     * @return mixed
445
     */
446
    public function avg($column);
447
448
    /**
449
     * Retrieve the sum of the values of a given column.
450
     *
451
     * @param string $column
452
     *
453
     * @return mixed
454
     */
455
    public function sum($column);
456
457
    /**
458
     * Dynamically pass missing static methods to the model.
459
     *
460
     * @param $method
461
     * @param $parameters
462
     *
463
     * @return mixed
464
     */
465
    public static function __callStatic($method, $parameters);
466
467
    /**
468
     * Dynamically pass missing methods to the model.
469
     *
470
     * @param string $method
471
     * @param array  $parameters
472
     *
473
     * @return mixed
474
     */
475
    public function __call($method, $parameters);
476
}
477