Passed
Push — develop ( 38bf9c...4f6606 )
by nguereza
12:50
created
src/Query/EntityQuery.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
     public function get(array $columns = [], bool $primaryColumn = true): ?Entity
149 149
     {
150 150
         $result = $this->query($columns, $primaryColumn)
151
-                       ->fetchAssoc()
152
-                       ->get();
151
+                        ->fetchAssoc()
152
+                        ->get();
153 153
 
154 154
         if ($result === false) {
155 155
             return null;
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
     }
299 299
 
300 300
 /**
301
-     * Find entities record using primary key values
302
-     * @param mixed ...$ids
303
-     *
304
-     * @return TEntity[]
305
-     */
301
+ * Find entities record using primary key values
302
+ * @param mixed ...$ids
303
+ *
304
+ * @return TEntity[]
305
+ */
306 306
     public function findAll(mixed ...$ids): array
307 307
     {
308 308
         if (is_array($ids[0])) {
@@ -543,6 +543,6 @@  discard block
 block discarded – undo
543 543
     protected function transaction(Closure $callback): mixed
544 544
     {
545 545
         return $this->manager->getConnection()
546
-                             ->transaction($callback);
546
+                                ->transaction($callback);
547 547
     }
548 548
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param string|array<int, string>|array<string, mixed> $names
116 116
      * @return $this
117 117
      */
118
-    public function filter(string|array $names): self
118
+    public function filter(string | array $names): self
119 119
     {
120 120
         if (!is_array($names)) {
121 121
             $names = [$names];
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
      */
210 210
     public function delete(bool $force = false, array $tables = []): int
211 211
     {
212
-        return (int) $this->transaction(function (Connection $connection) use ($tables, $force) {
212
+        return (int) $this->transaction(function(Connection $connection) use ($tables, $force) {
213 213
             if (!$force && $this->mapper->hasSoftDelete()) {
214 214
                 return (new Update($connection, $this->mapper->getTable(), $this->queryStatement))
215 215
                         ->set([
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function update(array $columns = []): int
229 229
     {
230
-        return (int) $this->transaction(function (Connection $connection) use ($columns) {
230
+        return (int) $this->transaction(function(Connection $connection) use ($columns) {
231 231
             if ($this->mapper->hasTimestamp()) {
232 232
                 list(, $updatedAtColumn) = $this->mapper->getTimestampColumns();
233 233
                 $columns[$updatedAtColumn] = date($this->manager->getDateFormat());
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
      * @param mixed $value
244 244
      * @return int
245 245
      */
246
-    public function increment(string|array $column, mixed $value = 1): int
246
+    public function increment(string | array $column, mixed $value = 1): int
247 247
     {
248
-        return (int) $this->transaction(function (Connection $connection) use ($column, $value) {
248
+        return (int) $this->transaction(function(Connection $connection) use ($column, $value) {
249 249
             if ($this->mapper->hasTimestamp()) {
250 250
                 list(, $updatedAtColumn) = $this->mapper->getTimestampColumns();
251 251
                 $this->queryStatement->addUpdateColumns([
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
      * @param mixed $value
264 264
      * @return int
265 265
      */
266
-    public function decrement(string|array $column, mixed $value = 1): int
266
+    public function decrement(string | array $column, mixed $value = 1): int
267 267
     {
268
-        return (int) $this->transaction(function (Connection $connection) use ($column, $value) {
268
+        return (int) $this->transaction(function(Connection $connection) use ($column, $value) {
269 269
             if ($this->mapper->hasTimestamp()) {
270 270
                 list(, $updatedAtColumn) = $this->mapper->getTimestampColumns();
271 271
                 $this->queryStatement->addUpdateColumns([
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      *
284 284
      * @return TEntity|null
285 285
      */
286
-    public function find(string|int|float|array $id): ?Entity
286
+    public function find(string | int | float | array $id): ?Entity
287 287
     {
288 288
         if (is_array($id)) {
289 289
             foreach ($id as $pkColumn => $pkValue) {
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @param string|Expression|Closure $column
332 332
      * @return mixed
333 333
      */
334
-    public function column(string|Expression|Closure $column): mixed
334
+    public function column(string | Expression | Closure $column): mixed
335 335
     {
336 336
         (new ColumnExpression($this->queryStatement))->column($column);
337 337
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      * @return mixed
346 346
      */
347 347
     public function count(
348
-        string|Expression|Closure $column = '*',
348
+        string | Expression | Closure $column = '*',
349 349
         bool $distinct = false
350 350
     ): mixed {
351 351
         (new ColumnExpression($this->queryStatement))->count($column, null, $distinct);
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
      * @return mixed
361 361
      */
362 362
     public function avg(
363
-        string|Expression|Closure $column,
363
+        string | Expression | Closure $column,
364 364
         bool $distinct = false
365 365
     ): mixed {
366 366
         (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct);
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      * @return mixed
376 376
      */
377 377
     public function sum(
378
-        string|Expression|Closure $column,
378
+        string | Expression | Closure $column,
379 379
         bool $distinct = false
380 380
     ): mixed {
381 381
         (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct);
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
      * @param bool $distinct
390 390
      * @return mixed
391 391
      */
392
-    public function min(string|Expression|Closure $column, bool $distinct = false): mixed
392
+    public function min(string | Expression | Closure $column, bool $distinct = false): mixed
393 393
     {
394 394
         (new ColumnExpression($this->queryStatement))->min($column, null, $distinct);
395 395
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
      * @return mixed
404 404
      */
405 405
     public function max(
406
-        string|Expression|Closure $column,
406
+        string | Expression | Closure $column,
407 407
         bool $distinct = false
408 408
     ): mixed {
409 409
         (new ColumnExpression($this->queryStatement))->max($column, null, $distinct);
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      * @param array<int, mixed>|false $results
470 470
      * @return array<string, \Platine\Orm\Relation\RelationLoader<TEntity>>
471 471
      */
472
-    protected function getRelationLoaders(array|false $results): array
472
+    protected function getRelationLoaders(array | false $results): array
473 473
     {
474 474
         if (empty($this->with) || empty($results)) {
475 475
             return [];
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@
 block discarded – undo
65 65
  * @package Platine\Orm\Query
66 66
  * @template TEntity as Entity
67 67
  */
68
-class EntityQuery extends Query
69
-{
68
+class EntityQuery extends Query {
70 69
     /**
71 70
      *
72 71
      * @var EntityManager<TEntity>
Please login to merge, or discard this patch.
src/Exception/RelationNotFoundException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,6 +38,5 @@
 block discarded – undo
38 38
  * @class RelationNotFoundException
39 39
  * @package Platine\Orm\Exception
40 40
  */
41
-class RelationNotFoundException extends RuntimeException
42
-{
41
+class RelationNotFoundException extends RuntimeException {
43 42
 }
Please login to merge, or discard this patch.
src/Exception/PropertyNotFoundException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,6 +38,5 @@
 block discarded – undo
38 38
  * @class PropertyNotFoundException
39 39
  * @package Platine\Orm\Exception
40 40
  */
41
-class PropertyNotFoundException extends RuntimeException
42
-{
41
+class PropertyNotFoundException extends RuntimeException {
43 42
 }
Please login to merge, or discard this patch.
src/Exception/EntityStateException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,6 +38,5 @@
 block discarded – undo
38 38
  * @class EntityStateException
39 39
  * @package Platine\Orm\Exception
40 40
  */
41
-class EntityStateException extends RuntimeException
42
-{
41
+class EntityStateException extends RuntimeException {
43 42
 }
Please login to merge, or discard this patch.
src/EntityManager.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -58,8 +58,7 @@  discard block
 block discarded – undo
58 58
  * @package Platine\Orm
59 59
  * @template TEntity as Entity
60 60
  */
61
-class EntityManager
62
-{
61
+class EntityManager {
63 62
     /**
64 63
      * The date format
65 64
      * @var string
@@ -76,8 +75,7 @@  discard block
 block discarded – undo
76 75
      * Create new instance
77 76
      * @param Connection $connection
78 77
      */
79
-    public function __construct(protected Connection $connection)
80
-    {
78
+    public function __construct(protected Connection $connection) {
81 79
         $this->dateFormat = $connection->getDriver()->getDateFormat();
82 80
     }
83 81
 
Please login to merge, or discard this patch.
src/Mapper/DataMapper.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
         }
318 318
     }
319 319
 
320
-     /**
321
-     * {@inheritedoc}
322
-     */
320
+        /**
321
+         * {@inheritedoc}
322
+         */
323 323
     public function hasColumn(string $column): bool
324 324
     {
325 325
         return array_key_exists($column, $this->columns)
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
         $this->rawColumns[$name] = $value;
353 353
     }
354 354
 
355
-     /**
356
-     * {@inheritedoc}
357
-     */
355
+        /**
356
+         * {@inheritedoc}
357
+         */
358 358
     public function getRelated(string $name, callable $callback = null): mixed
359 359
     {
360 360
         if (array_key_exists($name, $this->relations)) {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@
 block discarded – undo
66 66
  * @template TEntity as Entity
67 67
  * @implements DataMapperInterface<TEntity>
68 68
  */
69
-class DataMapper implements DataMapperInterface
70
-{
69
+class DataMapper implements DataMapperInterface {
71 70
     /**
72 71
      * The raw columns data
73 72
      * @var array<string, mixed>
Please login to merge, or discard this patch.
src/Mapper/EntityMapper.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
         return $this;
222 222
     }
223 223
 
224
-     /**
225
-     * {@inheritedoc}
226
-     * @return EntityMapper<TEntity>
227
-     */
224
+        /**
225
+         * {@inheritedoc}
226
+         * @return EntityMapper<TEntity>
227
+         */
228 228
     public function sequence(string $sequence): self
229 229
     {
230 230
         $this->sequence = $sequence;
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
         return $this;
255 255
     }
256 256
 
257
-     /**
258
-     * {@inheritedoc}
259
-     * @return EntityMapper<TEntity>
260
-     */
257
+        /**
258
+         * {@inheritedoc}
259
+         * @return EntityMapper<TEntity>
260
+         */
261 261
     public function guarded(array $columns): self
262 262
     {
263 263
         $this->guarded = $columns;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -320,7 +320,7 @@
 block discarded – undo
320 320
     public function relation(string $name): RelationFactory
321 321
     {
322 322
         /** @var RelationFactory<TEntity> $factory */
323
-        $factory = new RelationFactory($name, function ($name, Relation $relation) {
323
+        $factory = new RelationFactory($name, function($name, Relation $relation) {
324 324
             return $this->relations[$name] = $relation;
325 325
         });
326 326
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,8 +57,7 @@  discard block
 block discarded – undo
57 57
  * @template TEntity as \Platine\Orm\Entity
58 58
  * @implements EntityMapperInterface<TEntity>
59 59
  */
60
-class EntityMapper implements EntityMapperInterface
61
-{
60
+class EntityMapper implements EntityMapperInterface {
62 61
     /**
63 62
      * The name of the entity
64 63
      * @var string
@@ -173,8 +172,7 @@  discard block
 block discarded – undo
173 172
      * Create new instance
174 173
      * @param class-string<TEntity> $entityClass
175 174
      */
176
-    public function __construct(protected string $entityClass)
177
-    {
175
+    public function __construct(protected string $entityClass) {
178 176
     }
179 177
 
180 178
     /**
@@ -448,15 +446,13 @@  discard block
 block discarded – undo
448 446
             $primaryKey = $this->getPrimaryKey();
449 447
             $prefix = $this->getName();
450 448
 
451
-            $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey
452
-            {
449
+            $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey {
453 450
                 /**
454 451
                  *
455 452
                  * @param PrimaryKey<TEntity> $primaryKey
456 453
                  * @param string $prefix
457 454
                  */
458
-                public function __construct(PrimaryKey $primaryKey, string $prefix)
459
-                {
455
+                public function __construct(PrimaryKey $primaryKey, string $prefix) {
460 456
                     /** @var array<string, string> $columns */
461 457
                     $columns = [];
462 458
 
@@ -475,8 +471,7 @@  discard block
 block discarded – undo
475 471
      *
476 472
      * @return callable|null
477 473
      */
478
-    public function getPrimaryKeyGenerator()
479
-    {
474
+    public function getPrimaryKeyGenerator() {
480 475
         return $this->primaryKeyGenerator;
481 476
     }
482 477
 
Please login to merge, or discard this patch.
src/RepositoryInterface.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      * @param bool $immediate
64 64
      * @return EntityQuery<TEntity>
65 65
      */
66
-    public function query(string|array $with = [], bool $immediate = false): EntityQuery;
66
+    public function query(string | array $with = [], bool $immediate = false): EntityQuery;
67 67
 
68 68
     /**
69 69
      * Load with relation
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      * @param bool $immediate
72 72
      * @return self<TEntity>
73 73
      */
74
-    public function with(string|array $with, bool $immediate = false): self;
74
+    public function with(string | array $with, bool $immediate = false): self;
75 75
 
76 76
     /**
77 77
      * Set order
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      * @return self<TEntity>
81 81
      */
82 82
     public function orderBy(
83
-        string|Closure|Expression|array $columns,
83
+        string | Closure | Expression | array $columns,
84 84
         string $order = 'ASC'
85 85
     ): self;
86 86
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param string|array<string, mixed> $filters
98 98
      * @return self<TEntity>
99 99
      */
100
-    public function filters(string|array $filters = []): self;
100
+    public function filters(string | array $filters = []): self;
101 101
 
102 102
     /**
103 103
      * Create the instance of Entity
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
      * @param TEntity $entity
112 112
      * @return array<mixed>|string|int|float|bool|null
113 113
      */
114
-    public function save(Entity $entity): array|string|int|float|bool|null;
114
+    public function save(Entity $entity): array | string | int | float | bool | null;
115 115
 
116 116
     /**
117 117
      * Save the new entity in data store
118 118
      * @param TEntity $entity
119 119
      * @return array<mixed>|string|int|float|false|null the primary key(s) value(s)
120 120
      */
121
-    public function insert(Entity $entity): array|string|int|float|false|null;
121
+    public function insert(Entity $entity): array | string | int | float | false | null;
122 122
 
123 123
     /**
124 124
      * Update the existing entity in data store
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      *
149 149
      * @return TEntity|null
150 150
      */
151
-    public function find(array|string|int|float $id): ?Entity;
151
+    public function find(array | string | int | float $id): ?Entity;
152 152
 
153 153
     /**
154 154
      * Find one entity instance using some conditions
Please login to merge, or discard this patch.
src/Repository.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      * The order by column(s)
84 84
      * @var string|Closure|Expression|string[]|Expression[]|Closure[]
85 85
      */
86
-    protected string|Closure|Expression|array $orderColumns = '';
86
+    protected string | Closure | Expression | array $orderColumns = '';
87 87
 
88 88
     /**
89 89
      * The order direction
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     /**
124 124
      * {@inheritedoc}
125 125
      */
126
-    public function query(string|array $with = [], bool $immediate = false): EntityQuery
126
+    public function query(string | array $with = [], bool $immediate = false): EntityQuery
127 127
     {
128 128
         if (is_string($with)) {
129 129
             $with = [$with];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * {@inheritedoc}
165 165
      * @return self<TEntity>
166 166
      */
167
-    public function with(string|array $with, bool $immediate = false): self
167
+    public function with(string | array $with, bool $immediate = false): self
168 168
     {
169 169
         if (!is_array($with)) {
170 170
             $with = [$with];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
      * @return self<TEntity>
181 181
      */
182 182
     public function orderBy(
183
-        string|Closure|Expression|array $columns,
183
+        string | Closure | Expression | array $columns,
184 184
         string $order = 'ASC'
185 185
     ): self {
186 186
         $this->orderColumns = $columns;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * {@inheritedoc}
206 206
      * @return self<TEntity>
207 207
      */
208
-    public function filters(string|array $filters = []): self
208
+    public function filters(string | array $filters = []): self
209 209
     {
210 210
         if (is_string($filters)) {
211 211
             $filters = [$filters => true];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     /**
245 245
      * {@inheritedoc}
246 246
      */
247
-    public function find(array|string|int|float $id): ?Entity
247
+    public function find(array | string | int | float $id): ?Entity
248 248
     {
249 249
         return $this->query()->find($id);
250 250
     }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     /**
285 285
      * {@inheritedoc}
286 286
      */
287
-    public function save(Entity $entity): array|string|int|float|bool|null
287
+    public function save(Entity $entity): array | string | int | float | bool | null
288 288
     {
289 289
         $data = Proxy::instance()->getEntityDataMapper($entity);
290 290
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     /**
299 299
      * {@inheritedoc}
300 300
      */
301
-    public function insert(Entity $entity): array|string|int|float|false|null
301
+    public function insert(Entity $entity): array | string | int | float | false | null
302 302
     {
303 303
         $data = Proxy::instance()->getEntityDataMapper($entity);
304 304
         $mapper = $data->getEntityMapper();
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         }
314 314
 
315 315
         $connection = $this->manager->getConnection();
316
-        $id = $connection->transaction(function (Connection $connection) use ($data, $mapper) {
316
+        $id = $connection->transaction(function(Connection $connection) use ($data, $mapper) {
317 317
             $columns = $data->getRawColumns();
318 318
             $pkGenerator = $mapper->getPrimaryKeyGenerator();
319 319
             if ($pkGenerator !== null) {
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
         $modified = $data->getModifiedColumns();
384 384
         if (!empty($modified)) {
385 385
             $connection = $this->manager->getConnection();
386
-            $result = $connection->transaction(function (Connection $connection) use ($data, $mapper, $modified) {
386
+            $result = $connection->transaction(function(Connection $connection) use ($data, $mapper, $modified) {
387 387
                 $columns = array_intersect_key($data->getRawColumns(), array_flip($modified));
388 388
 
389 389
                 $updatedAt = null;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         }
421 421
 
422 422
         $connection = $this->manager->getConnection();
423
-        return $connection->transaction(function (Connection $connection) use ($data) {
423
+        return $connection->transaction(function(Connection $connection) use ($data) {
424 424
             $data->executePendingLinkage();
425 425
 
426 426
             return true;
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
         $eventsHandlers = $mapper->getEventHandlers();
438 438
         $connection = $this->manager->getConnection();
439 439
 
440
-        $result = $connection->transaction(function () use ($data, $mapper, $force) {
440
+        $result = $connection->transaction(function() use ($data, $mapper, $force) {
441 441
             if ($data->isDeleted()) {
442 442
                 throw new EntityStateException('The record was deleted');
443 443
             }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@
 block discarded – undo
65 65
  * @template TEntity as Entity
66 66
  * @implements RepositoryInterface<TEntity>
67 67
  */
68
-class Repository implements RepositoryInterface
69
-{
68
+class Repository implements RepositoryInterface {
70 69
     /**
71 70
      * The list of relation to load with the query
72 71
      * @var array<int, string>|array<string, Closure>
Please login to merge, or discard this patch.