Issues (56)

src/RepositoryInterface.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * Platine ORM
5
 *
6
 * Platine ORM provides a flexible and powerful ORM implementing a data-mapper pattern.
7
 *
8
 * This content is released under the MIT License (MIT)
9
 *
10
 * Copyright (c) 2020 Platine ORM
11
 *
12
 * Permission is hereby granted, free of charge, to any person obtaining a copy
13
 * of this software and associated documentation files (the "Software"), to deal
14
 * in the Software without restriction, including without limitation the rights
15
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
 * copies of the Software, and to permit persons to whom the Software is
17
 * furnished to do so, subject to the following conditions:
18
 *
19
 * The above copyright notice and this permission notice shall be included in all
20
 * copies or substantial portions of the Software.
21
 *
22
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
 * SOFTWARE.
29
 */
30
31
/**
32
 *  @file RepositoryInterface.php
33
 *
34
 *  The RepositoryInterface class
35
 *
36
 *  @package    Platine\Orm
37
 *  @author Platine Developers Team
38
 *  @copyright  Copyright (c) 2020
39
 *  @license    http://opensource.org/licenses/MIT  MIT License
40
 *  @link   https://www.platine-php.com
41
 *  @version 1.0.0
42
 *  @filesource
43
 */
44
45
declare(strict_types=1);
46
47
namespace Platine\Orm;
48
49
use Closure;
50
use Platine\Database\Query\Expression;
51
use Platine\Orm\Query\EntityQuery;
52
53
/**
54
 * @class RepositoryInterface
55
 * @package Platine\Orm
56
 * @template TEntity as Entity
57
 */
58
interface RepositoryInterface
59
{
60
    /**
61
     * Return the instance of EntityQuery
62
     * @param string|array<int, string>|array<string, Closure> $with
63
     * @param bool $immediate
64
     * @return EntityQuery<TEntity>
65
     */
66
    public function query(string|array $with = [], bool $immediate = false): EntityQuery;
67
68
    /**
69
     * Load with relation
70
     * @param string|array<int, string>|array<string, Closure> $with
71
     * @param bool $immediate
72
     * @return self<TEntity>
73
     */
74
    public function with(string|array $with, bool $immediate = false): self;
75
76
    /**
77
     * Set order
78
     * @param string|Closure|Expression|string[]|Expression[]|Closure[] $columns
79
     * @param string $order
80
     * @return self<TEntity>
81
     */
82
    public function orderBy(
83
        string|Closure|Expression|array $columns,
84
        string $order = 'ASC'
85
    ): self;
86
87
    /**
88
     * Add limit and offset
89
     * @param int $offset
90
     * @param int $limit
91
     * @return self<TEntity>
92
     */
93
    public function limit(int $offset, int $limit): self;
94
95
    /**
96
     * Apply an filters on the query
97
     * @param string|array<string, mixed> $filters
98
     * @return self<TEntity>
99
     */
100
    public function filters(string|array $filters = []): self;
101
102
    /**
103
     * Create the instance of Entity
104
     * @param array<string, mixed> $columns initial data
105
     * @return TEntity
0 ignored issues
show
The type Platine\Orm\TEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
106
     */
107
    public function create(array $columns = []): Entity;
108
109
    /**
110
     * Shortcut to "insert" and "update" the entity in data store
111
     * @param TEntity $entity
112
     * @return array<mixed>|string|int|float|bool|null
113
     */
114
    public function save(Entity $entity): array|string|int|float|bool|null;
115
116
    /**
117
     * Save the new entity in data store
118
     * @param TEntity $entity
119
     * @return array<mixed>|string|int|float|false|null the primary key(s) value(s)
120
     */
121
    public function insert(Entity $entity): array|string|int|float|false|null;
122
123
    /**
124
     * Update the existing entity in data store
125
     * @param TEntity $entity
126
     * @return bool
127
     */
128
    public function update(Entity $entity): bool;
129
130
    /**
131
     * Delete the entity
132
     * @param TEntity $entity
133
     * @param bool $force
134
     * @return bool
135
     */
136
    public function delete(Entity $entity, bool $force = false): bool;
137
138
    /**
139
     *
140
     * @param array<int, string> $columns
141
     * @return TEntity[]
142
     */
143
    public function all(array $columns = []): array;
144
145
    /**
146
     * Find one entity instance
147
     * @param array<mixed>|string|int|float $id
148
     *
149
     * @return TEntity|null
150
     */
151
    public function find(array|string|int|float $id): ?Entity;
152
153
    /**
154
     * Find one entity instance using some conditions
155
     * @param array<string, mixed> $conditions
156
     *
157
     * @return TEntity|null
158
     */
159
    public function findBy(array $conditions): ?Entity;
160
161
    /**
162
     * Find the list of record using many primary key
163
     * @param mixed ...$ids
164
     * @return TEntity[]
165
     */
166
    public function findAll(mixed ...$ids): array;
167
168
    /**
169
     * Find the list of record using some conditions
170
     * @param array<string, mixed> $conditions
171
     * @return TEntity[]
172
     */
173
    public function findAllBy(array $conditions): array;
174
}
175