Issues (56)

src/Mapper/DataMapperInterface.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 DataMapperInterface.php
33
 *
34
 *  The Data Mapper Interface
35
 *
36
 *  @package    Platine\Orm\Mapper
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\Mapper;
48
49
use Platine\Orm\Entity;
50
51
/**
52
 * @class DataMapperInterface
53
 * @package Platine\Orm\Mapper
54
 * @template TEntity as Entity
55
 */
56
interface DataMapperInterface
57
{
58
    /**
59
     * Whether the record is new
60
     * @return bool
61
     */
62
    public function isNew(): bool;
63
64
    /**
65
     * Whether the record is read only
66
     * @return bool
67
     */
68
    public function isReadOnly(): bool;
69
70
    /**
71
     * Whether the record is deleted
72
     * @return bool
73
     */
74
    public function isDeleted(): bool;
75
76
    /**
77
     * Whether the record was modified
78
     * @return bool
79
     */
80
    public function wasModified(): bool;
81
82
    /**
83
     * Whether the entity has the given column
84
     * @param string $column
85
     * @return bool
86
     */
87
    public function hasColumn(string $column): bool;
88
89
    /**
90
     * Whether the entity has the given related
91
     * @param string $relation
92
     * @return bool
93
     */
94
    public function hasRelation(string $relation): bool;
95
96
    /**
97
     * Return the raw columns data
98
     *
99
     * @return array<string, mixed>
100
     */
101
    public function getRawColumns(): array;
102
103
    /**
104
     * Return the modified columns data
105
     *
106
     * @return array<int, string>
107
     */
108
    public function getModifiedColumns(): array;
109
110
    /**
111
     * Return the value for the given column
112
     * @param string $name
113
     *
114
     * @return mixed
115
     */
116
    public function getColumn(string $name): mixed;
117
118
    /**
119
     * Set the value for the given column
120
     * @param string $name
121
     * @param mixed $value
122
     *
123
     * @return void
124
     */
125
    public function setColumn(string $name, mixed $value): void;
126
127
    /**
128
     * Clear the value for the given column
129
     * @param string $name
130
     * @param bool $raw whether to clear raw column too
131
     *
132
     * @return void
133
     */
134
    public function clearColumn(string $name, bool $raw = false): void;
135
136
    /**
137
     * Set the raw value for the given column
138
     * @param string $name
139
     * @param mixed $value
140
     *
141
     * @return void
142
     */
143
    public function setRawColumn(string $name, mixed $value): void;
144
145
    /**
146
     * Return the value for the given relation
147
     * @param string $name
148
     * @param callable|null $callback
149
     *
150
     * @return mixed
151
     */
152
    public function getRelated(string $name, callable $callback = null): mixed;
153
154
    /**
155
     * Set the value for the given relation
156
     * @param string $name
157
     * @param TEntity|null $entity
0 ignored issues
show
The type Platine\Orm\Mapper\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...
158
     *
159
     * @return void
160
     */
161
    public function setRelated(string $name, ?Entity $entity = null): void;
162
163
    /**
164
     * Clear the given relation data
165
     * @param string $name
166
     * @param bool $loaders
167
     * @return void
168
     */
169
    public function clearRelated(string $name, bool $loaders = false): void;
170
171
    /**
172
     * Make a link between for the given relation and entity
173
     * @param string $relation
174
     * @param TEntity $entity
175
     * @return void
176
     */
177
    public function link(string $relation, Entity $entity): void;
178
179
    /**
180
     * Remove the link between for the given relation and entity
181
     * @param string $relation
182
     * @param TEntity $entity
183
     * @return void
184
     */
185
    public function unlink(string $relation, Entity $entity): void;
186
187
188
    /**
189
     * Fill the entity information using the given columns data
190
     * @param array<string, mixed> $columns
191
     * @return void
192
     */
193
    public function fill(array $columns): void;
194
195
196
    /**
197
     * Reload the entity data from data source
198
     * @return void
199
     */
200
    public function refresh(): void;
201
}
202