Passed
Push — develop ( 3ec3b4...7073d3 )
by nguereza
01:54
created
src/Relation/ShareRelation.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
         /**
101
-     *
102
-     * @param DataMapper<TEntity> $mapper
103
-     * @param TEntity $entity
104
-     *
105
-     * @return bool
106
-     */
101
+         *
102
+         * @param DataMapper<TEntity> $mapper
103
+         * @param TEntity $entity
104
+         *
105
+         * @return bool
106
+         */
107 107
     public function link(DataMapper $mapper, Entity $entity): bool
108 108
     {
109 109
         $manager = $mapper->getEntityManager();
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             }
385 385
         });
386 386
 
387
-         $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true);
387
+            $foreignKeys = $this->foreignKey->getValue($mapper->getRawColumns(), true);
388 388
         if (is_array($foreignKeys)) {
389 389
             foreach ($foreignKeys as $fkColumn => $value) {
390 390
                 $select->where($junctionTable . '.' . $fkColumn)->is($value);
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@  discard block
 block discarded – undo
68 68
  * @template TEntity as Entity
69 69
  * @extends Relation<TEntity>
70 70
  */
71
-abstract class ShareRelation extends Relation
72
-{
71
+abstract class ShareRelation extends Relation {
73 72
     /**
74 73
      * Whether is many or not
75 74
      * @var bool
@@ -218,8 +217,7 @@  discard block
 block discarded – undo
218 217
 
219 218
         $queryStatement = new QueryStatement();
220 219
         
221
-        $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery
222
-        {
220
+        $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery {
223 221
             /**
224 222
              *
225 223
              * @var string
@@ -311,8 +309,7 @@  discard block
 block discarded – undo
311 309
      * {@inheritedoc}
312 310
      * @param DataMapper<TEntity> $mapper
313 311
      */
314
-    public function getResult(DataMapper $mapper, ?callable $callback = null)
315
-    {
312
+    public function getResult(DataMapper $mapper, ?callable $callback = null) {
316 313
         $manager = $mapper->getEntityManager();
317 314
         $owner = $mapper->getEntityMapper();
318 315
         $related = $manager->getEntityMapper($this->entityClass);
@@ -329,8 +326,7 @@  discard block
 block discarded – undo
329 326
         $joinTable = $related->getTable();
330 327
 
331 328
         $queryStatement = new QueryStatement();
332
-        $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery
333
-        {
329
+        $select = new class ($manager, $related, $queryStatement, $junctionTable) extends EntityQuery {
334 330
             /**
335 331
              *
336 332
              * @var string
@@ -418,15 +414,13 @@  discard block
 block discarded – undo
418 414
      */
419 415
     protected function buildJunction(EntityMapper $owner, EntityMapper $related): Junction
420 416
     {
421
-        return new class ($owner, $related) extends Junction
422
-        {
417
+        return new class ($owner, $related) extends Junction {
423 418
             /**
424 419
              *
425 420
              * @param EntityMapper<TEntity> $owner
426 421
              * @param EntityMapper<TEntity> $related
427 422
              */
428
-            public function __construct(EntityMapper $owner, EntityMapper $related)
429
-            {
423
+            public function __construct(EntityMapper $owner, EntityMapper $related) {
430 424
                 $table = [$owner->getTable(), $related->getTable()];
431 425
                 sort($table);
432 426
                 parent::__construct(implode('_', $table), $related->getForeignKey()->columns());
Please login to merge, or discard this patch.
src/Relation/ForeignKey.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@  discard block
 block discarded – undo
50 50
  * @class ForeignKey
51 51
  * @package Platine\Orm\Relation
52 52
  */
53
-class ForeignKey
54
-{
53
+class ForeignKey {
55 54
     /**
56 55
      *
57 56
      * @var array<string, string>
@@ -68,8 +67,7 @@  discard block
 block discarded – undo
68 67
      * Create new instance
69 68
      * @param array<string, string> $columns
70 69
      */
71
-    public function __construct(array $columns)
72
-    {
70
+    public function __construct(array $columns) {
73 71
         $this->columns = $columns;
74 72
         $this->composite = count($columns) > 1;
75 73
     }
@@ -99,8 +97,7 @@  discard block
 block discarded – undo
99 97
      *
100 98
      * @return mixed|array<string, mixed>|null
101 99
      */
102
-    public function getValue(array $columns, bool $map = false)
103
-    {
100
+    public function getValue(array $columns, bool $map = false) {
104 101
         if (!$map && !$this->composite) {
105 102
             $column = array_keys($this->columns);
106 103
 
@@ -127,8 +124,7 @@  discard block
 block discarded – undo
127 124
      *
128 125
      * @return mixed|array<string, mixed>|null
129 126
      */
130
-    public function getInverseValue(array $columns, bool $map = false)
131
-    {
127
+    public function getInverseValue(array $columns, bool $map = false) {
132 128
         if (!$map && !$this->composite) {
133 129
             $column = array_values($this->columns);
134 130
 
@@ -154,8 +150,7 @@  discard block
 block discarded – undo
154 150
      *
155 151
      * @return mixed|array<string, mixed>|null
156 152
      */
157
-    public function extractValue(array $columns, bool $map = false)
158
-    {
153
+    public function extractValue(array $columns, bool $map = false) {
159 154
         if (!$map && !$this->composite) {
160 155
             $column = array_values($this->columns);
161 156
 
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 connection
65 64
      * @var Connection
@@ -82,8 +81,7 @@  discard block
 block discarded – undo
82 81
      * Create new instance
83 82
      * @param Connection $connection
84 83
      */
85
-    public function __construct(Connection $connection)
86
-    {
84
+    public function __construct(Connection $connection) {
87 85
         $this->connection = $connection;
88 86
         $this->dateFormat = $connection->getDriver()->getDateFormat();
89 87
     }
Please login to merge, or discard this patch.
src/Entity.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -199,9 +199,9 @@
 block discarded – undo
199 199
     }
200 200
 
201 201
         /**
202
-     * Map the entity information
203
-     * @param EntityMapperInterface<TEntity> $mapper
204
-     */
202
+         * Map the entity information
203
+         * @param EntityMapperInterface<TEntity> $mapper
204
+         */
205 205
     abstract public static function mapEntity(EntityMapperInterface $mapper): void;
206 206
 
207 207
     /**
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 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
-abstract class Entity implements JsonSerializable
62
-{
61
+abstract class Entity implements JsonSerializable {
63 62
     /**
64 63
      * The instance of data mapper
65 64
      * @var DataMapper<TEntity> |null
@@ -103,8 +102,7 @@  discard block
 block discarded – undo
103 102
      * Convert entity to JSON array
104 103
      * @return array<string, mixed>
105 104
      */
106
-    public function jsonSerialize()
107
-    {
105
+    public function jsonSerialize() {
108 106
         $rawColumns = $this->mapper()->getRawColumns();
109 107
         $data = [];
110 108
         foreach ($rawColumns as $name => $value) {
@@ -125,8 +123,7 @@  discard block
 block discarded – undo
125 123
      * @param string $name
126 124
      * @return mixed
127 125
      */
128
-    public function __get(string $name)
129
-    {
126
+    public function __get(string $name) {
130 127
         if ($this->mapper()->hasRelation($name)) {
131 128
             return $this->mapper()->getRelated($name);
132 129
         }
@@ -147,8 +144,7 @@  discard block
 block discarded – undo
147 144
      * @param mixed $value
148 145
      * @return void
149 146
      */
150
-    public function __set(string $name, $value)
151
-    {
147
+    public function __set(string $name, $value) {
152 148
         if ($this->mapper()->hasRelation($name)) {
153 149
             if (is_array($value)) {
154 150
                 foreach ($value as $entity) {
@@ -167,8 +163,7 @@  discard block
 block discarded – undo
167 163
      * @param string $name
168 164
      * @return bool
169 165
      */
170
-    public function __isset(string $name)
171
-    {
166
+    public function __isset(string $name) {
172 167
         return $this->mapper()->hasRelation($name)
173 168
                 || $this->mapper()->hasColumn($name);
174 169
     }
@@ -178,8 +173,7 @@  discard block
 block discarded – undo
178 173
      * @param string $name
179 174
      * @return bool
180 175
      */
181
-    public function __unset(string $name)
182
-    {
176
+    public function __unset(string $name) {
183 177
         $this->mapper()->clearColumn($name, true);
184 178
     }
185 179
 
Please login to merge, or discard this patch.
src/Query/EntityQuery.php 2 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(...$ids): array
307 307
     {
308 308
         if (is_array($ids[0])) {
@@ -535,6 +535,6 @@  discard block
 block discarded – undo
535 535
     protected function transaction(Closure $callback)
536 536
     {
537 537
         return $this->manager->getConnection()
538
-                             ->transaction($callback);
538
+                                ->transaction($callback);
539 539
     }
540 540
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,8 +65,7 @@  discard block
 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>
@@ -331,8 +330,7 @@  discard block
 block discarded – undo
331 330
      * @param string|Expression|Closure $column
332 331
      * @return mixed
333 332
      */
334
-    public function column($column)
335
-    {
333
+    public function column($column) {
336 334
         (new ColumnExpression($this->queryStatement))->column($column);
337 335
 
338 336
         return $this->executeAggregate();
@@ -344,8 +342,7 @@  discard block
 block discarded – undo
344 342
      * @param bool $distinct
345 343
      * @return mixed
346 344
      */
347
-    public function count($column = '*', bool $distinct = false)
348
-    {
345
+    public function count($column = '*', bool $distinct = false) {
349 346
         (new ColumnExpression($this->queryStatement))->count($column, null, $distinct);
350 347
 
351 348
         return $this->executeAggregate();
@@ -357,8 +354,7 @@  discard block
 block discarded – undo
357 354
      * @param bool $distinct
358 355
      * @return mixed
359 356
      */
360
-    public function avg($column, bool $distinct = false)
361
-    {
357
+    public function avg($column, bool $distinct = false) {
362 358
         (new ColumnExpression($this->queryStatement))->avg($column, null, $distinct);
363 359
 
364 360
         return $this->executeAggregate();
@@ -370,8 +366,7 @@  discard block
 block discarded – undo
370 366
      * @param bool $distinct
371 367
      * @return mixed
372 368
      */
373
-    public function sum($column, bool $distinct = false)
374
-    {
369
+    public function sum($column, bool $distinct = false) {
375 370
         (new ColumnExpression($this->queryStatement))->sum($column, null, $distinct);
376 371
 
377 372
         return $this->executeAggregate();
@@ -383,8 +378,7 @@  discard block
 block discarded – undo
383 378
      * @param bool $distinct
384 379
      * @return mixed
385 380
      */
386
-    public function min($column, bool $distinct = false)
387
-    {
381
+    public function min($column, bool $distinct = false) {
388 382
         (new ColumnExpression($this->queryStatement))->min($column, null, $distinct);
389 383
 
390 384
         return $this->executeAggregate();
@@ -396,8 +390,7 @@  discard block
 block discarded – undo
396 390
      * @param bool $distinct
397 391
      * @return mixed
398 392
      */
399
-    public function max($column, bool $distinct = false)
400
-    {
393
+    public function max($column, bool $distinct = false) {
401 394
         (new ColumnExpression($this->queryStatement))->max($column, null, $distinct);
402 395
 
403 396
         return $this->executeAggregate();
@@ -406,8 +399,7 @@  discard block
 block discarded – undo
406 399
     /**
407 400
      * Clone of object
408 401
      */
409
-    public function __clone()
410
-    {
402
+    public function __clone() {
411 403
         parent::__clone();
412 404
         $this->havingStatement = new HavingStatement($this->queryStatement);
413 405
     }
@@ -496,8 +488,7 @@  discard block
 block discarded – undo
496 488
      * Execute the aggregate
497 489
      * @return mixed
498 490
      */
499
-    protected function executeAggregate()
500
-    {
491
+    protected function executeAggregate() {
501 492
         $this->queryStatement->addTables([$this->mapper->getTable()]);
502 493
 
503 494
         if ($this->mapper->hasSoftDelete()) {
@@ -532,8 +523,7 @@  discard block
 block discarded – undo
532 523
      *
533 524
      * @return mixed
534 525
      */
535
-    protected function transaction(Closure $callback)
536
-    {
526
+    protected function transaction(Closure $callback) {
537 527
         return $this->manager->getConnection()
538 528
                              ->transaction($callback);
539 529
     }
Please login to merge, or discard this patch.
src/Mapper/Proxy.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 60
  * @package Platine\Orm\Mapper
61 61
  * @template TEntity as Entity
62 62
  */
63
-class Proxy
64
-{
63
+class Proxy {
65 64
     /**
66 65
      * The Entity data mapper arguments property
67 66
      * @var ReflectionProperty
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
      * Create new instance
79 78
      * @throws ReflectionException
80 79
      */
81
-    private function __construct()
82
-    {
80
+    private function __construct() {
83 81
         $reflection = new ReflectionClass(Entity::class);
84 82
 
85 83
         $this->dataMapperArgs = $reflection->getProperty('dataMapperArgs');
Please login to merge, or discard this patch.
src/Mapper/EntityMapper.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
         return $this;
229 229
     }
230 230
 
231
-     /**
232
-     * {@inheritedoc}
233
-     * @return $this<TEntity>
234
-     */
231
+        /**
232
+         * {@inheritedoc}
233
+         * @return $this<TEntity>
234
+         */
235 235
     public function sequence(string $sequence): self
236 236
     {
237 237
         $this->sequence = $sequence;
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
         return $this;
262 262
     }
263 263
 
264
-     /**
265
-     * {@inheritedoc}
266
-     * @return $this<TEntity>
267
-     */
264
+        /**
265
+         * {@inheritedoc}
266
+         * @return $this<TEntity>
267
+         */
268 268
     public function guarded(array $columns): self
269 269
     {
270 270
         $this->guarded = $columns;
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
@@ -179,8 +178,7 @@  discard block
 block discarded – undo
179 178
      * Create new instance
180 179
      * @param class-string<TEntity> $entityClass
181 180
      */
182
-    public function __construct(string $entityClass)
183
-    {
181
+    public function __construct(string $entityClass) {
184 182
         $this->entityClass = $entityClass;
185 183
     }
186 184
 
@@ -452,15 +450,13 @@  discard block
 block discarded – undo
452 450
             $primaryKey = $this->getPrimaryKey();
453 451
             $prefix = $this->getName();
454 452
 
455
-            $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey
456
-            {
453
+            $this->foreignKey = new class ($primaryKey, $prefix) extends ForeignKey {
457 454
                 /**
458 455
                  *
459 456
                  * @param PrimaryKey<TEntity> $primaryKey
460 457
                  * @param string $prefix
461 458
                  */
462
-                public function __construct(PrimaryKey $primaryKey, string $prefix)
463
-                {
459
+                public function __construct(PrimaryKey $primaryKey, string $prefix) {
464 460
                     /** @var array<string, string> $columns */
465 461
                     $columns = [];
466 462
 
@@ -479,8 +475,7 @@  discard block
 block discarded – undo
479 475
      *
480 476
      * @return callable|null
481 477
      */
482
-    public function getPrimaryKeyGenerator()
483
-    {
478
+    public function getPrimaryKeyGenerator() {
484 479
         return $this->primaryKeyGenerator;
485 480
     }
486 481
 
Please login to merge, or discard this patch.
src/Mapper/DataMapper.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,8 +66,7 @@  discard block
 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>
@@ -229,8 +228,7 @@  discard block
 block discarded – undo
229 228
     /**
230 229
      * {@inheritedoc}
231 230
      */
232
-    public function getColumn(string $name)
233
-    {
231
+    public function getColumn(string $name) {
234 232
         if ($this->refresh) {
235 233
             $this->hydrate();
236 234
         }
@@ -355,8 +353,7 @@  discard block
 block discarded – undo
355 353
      /**
356 354
      * {@inheritedoc}
357 355
      */
358
-    public function getRelated(string $name, callable $callback = null)
359
-    {
356
+    public function getRelated(string $name, callable $callback = null) {
360 357
         if (array_key_exists($name, $this->relations)) {
361 358
             return $this->relations[$name];
362 359
         }
@@ -615,8 +612,7 @@  discard block
 block discarded – undo
615 612
      *
616 613
      * @return mixed
617 614
      */
618
-    protected function castGet($value, string $type)
619
-    {
615
+    protected function castGet($value, string $type) {
620 616
         $original = $type;
621 617
 
622 618
         if ($type[0] === '?') {
@@ -668,8 +664,7 @@  discard block
 block discarded – undo
668 664
      *
669 665
      * @return mixed
670 666
      */
671
-    protected function castSet($value, string $type)
672
-    {
667
+    protected function castSet($value, string $type) {
673 668
         $original = $type;
674 669
 
675 670
         if ($type[0] === '?') {
Please login to merge, or discard this patch.
src/Mapper/EntityMapperInterface.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,7 @@
 block discarded – undo
53 53
  * @package Platine\Orm\Mapper
54 54
  * @template TEntity as \Platine\Orm\Entity
55 55
  */
56
-interface EntityMapperInterface
57
-{
56
+interface EntityMapperInterface {
58 57
     /**
59 58
      * The name of the entity
60 59
      * @param string $name
Please login to merge, or discard this patch.