Passed
Push — main ( cb159e...cb4ec7 )
by Pranjal
02:27
created
src/Facade/Database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
      *
78 78
      * @return int|numeric-string
79 79
      */
80
-    public static function exec(string $sql): int|string
80
+    public static function exec(string $sql): int | string
81 81
     {
82 82
         return self::getDB()->exec($sql);
83 83
     }
Please login to merge, or discard this patch.
src/Database.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
      *
54 54
      * @return int|numeric-string
55 55
      */
56
-    public function exec(string $sql, array $params = []): int|string
56
+    public function exec(string $sql, array $params = []): int | string
57 57
     {
58 58
         return $this->connection->executeStatement($sql, $params);
59 59
     }
Please login to merge, or discard this patch.
rector.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@
 block discarded – undo
6 6
 
7 7
 return RectorConfig::configure()
8 8
     ->withPaths([
9
-        __DIR__ . '/src',
10
-        __DIR__ . '/tests',
9
+        __DIR__.'/src',
10
+        __DIR__.'/tests',
11 11
     ])
12 12
     // uncomment to reach your current PHP version
13 13
     ->withPhpSets(php83:true)
14 14
     ->withAttributesSets()
15
-    ->withPreparedSets(deadCode:true,typeDeclarations:true,codeQuality:true);
15
+    ->withPreparedSets(deadCode:true, typeDeclarations:true, codeQuality:true);
Please login to merge, or discard this patch.
src/Manager/ModelManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         // Try to load specific model class first if modelNamespace is not empty
41 41
         $namespace = $this->config->getModelNamespace();
42 42
         if (!empty($namespace)) {
43
-            $modelClass = $namespace . ucfirst($name);
43
+            $modelClass = $namespace.ucfirst($name);
44 44
             if (class_exists($modelClass)) {
45 45
                 return $this->container->make($modelClass);
46 46
             }
Please login to merge, or discard this patch.
src/Factory/DatabaseFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 
67 67
     private function createModelManager(): void
68 68
     {
69
-        $this->container->set(ModelManager::class, fn (): ModelManager => new ModelManager($this->container,$this->container->get(Config::class)));
69
+        $this->container->set(ModelManager::class, fn (): ModelManager => new ModelManager($this->container, $this->container->get(Config::class)));
70 70
     }
71 71
 
72 72
     private function createConfig(bool $useUUID, string $modelNamespace): void
Please login to merge, or discard this patch.
src/Model.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         }
238 238
 
239 239
         $db = $this->recordManager->find(strtolower((string) $parts[1]));
240
-        $db->where($this->getName() . '_id = :id')
240
+        $db->where($this->getName().'_id = :id')
241 241
             ->setParameter(
242 242
                 'id',
243 243
                 $this->__meta['id'],
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         $relTable = $this->getRelationTable($targetTable);
261 261
 
262 262
         $db = $this->recordManager->find($relTable);
263
-        $db->where($this->getName() . '_id = :id')
263
+        $db->where($this->getName().'_id = :id')
264 264
             ->setParameter(
265 265
                 'id',
266 266
                 $this->__meta['id'],
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 
292 292
     private function getRelationTable(string $targetTable): string
293 293
     {
294
-        $cacheKey = $this->table . '_' . $targetTable;
294
+        $cacheKey = $this->table.'_'.$targetTable;
295 295
 
296 296
         if (!isset($this->relationTableCache[$cacheKey])) {
297 297
             $this->relationTableCache[$cacheKey] = $this->tableManager->tableExists($cacheKey)
298 298
                 ? $cacheKey
299
-                : $targetTable . '_' . $this->table;
299
+                : $targetTable.'_'.$this->table;
300 300
         }
301 301
 
302 302
         return $this->relationTableCache[$cacheKey];
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 
305 305
     private function extractRelationIds(Collection $relations, string $targetTable): array
306 306
     {
307
-        return $relations->map(function ($relation) use ($targetTable) {
308
-            $key = $targetTable . '_id';
307
+        return $relations->map(function($relation) use ($targetTable) {
308
+            $key = $targetTable.'_id';
309 309
 
310 310
             return $relation->$key;
311 311
         })->toArray();
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
         }
333 333
 
334 334
         // Handle foreign key relations
335
-        if (array_key_exists($key . '_id', $this->__properties['self'])) {
336
-            $result = $this->recordManager->getById($key, $this->__properties['self'][$key . '_id']);
335
+        if (array_key_exists($key.'_id', $this->__properties['self'])) {
336
+            $result = $this->recordManager->getById($key, $this->__properties['self'][$key.'_id']);
337 337
             $this->set($key, $result);
338 338
 
339 339
             return $result;
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
      *
492 492
      * @throws Exception\InvalidModelException
493 493
      */
494
-    private function createCollection(?Collection $collection, array|Collection $models): Collection
494
+    private function createCollection(?Collection $collection, array | Collection $models): Collection
495 495
     {
496 496
         if (is_null($collection)) {
497 497
             $collection = Collection::fromIterable([]);
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
 
523 523
     private function handleModelRelation(string $key, Model $val): void
524 524
     {
525
-        if (isset($this->__properties['all'][$key . '_id'])) {
526
-            unset($this->__properties['all'][$key . '_id']);
525
+        if (isset($this->__properties['all'][$key.'_id'])) {
526
+            unset($this->__properties['all'][$key.'_id']);
527 527
         }
528 528
 
529 529
         $this->__meta['foreign_models']['oto'] = $this->createCollection(
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     /**
573 573
      * Determines the ParameterType for an ID value.
574 574
      */
575
-    private function determineIdType(int|string $id): ParameterType
575
+    private function determineIdType(int | string $id): ParameterType
576 576
     {
577 577
         return is_int($id) ? ParameterType::INTEGER : ParameterType::STRING;
578 578
     }
Please login to merge, or discard this patch.
src/Manager/WriteManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
             foreach ($model->getForeignModels(self::RELATION_ONE_TO_ONE) as $foreign) {
195 195
                 $id = $this->createRecords($foreign);
196 196
                 $this->finalizeModel($foreign);
197
-                $name = $foreign->getName() . self::ID_SUFFIX;
197
+                $name = $foreign->getName().self::ID_SUFFIX;
198 198
                 $model->$name = $id;
199 199
             }
200 200
         });
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $id = $model->getId();
209 209
         foreach ($model->getForeignModels(self::RELATION_ONE_TO_MANY) as $foreign) {
210
-            $key = $model->getName() . self::ID_SUFFIX;
210
+            $key = $model->getName().self::ID_SUFFIX;
211 211
             $foreign->$key = $id;
212 212
             $this->createTable($foreign, $this->createConstraintsOtm($model));
213 213
         }
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
     {
228 228
         $id = $model->getId();
229 229
         foreach ($model->getForeignModels(self::RELATION_MANY_TO_MANY) as $foreign) {
230
-            $model_id = $model->getName() . self::ID_SUFFIX;
231
-            $foreign_id = $foreign->getName() . self::ID_SUFFIX;
230
+            $model_id = $model->getName().self::ID_SUFFIX;
231
+            $foreign_id = $foreign->getName().self::ID_SUFFIX;
232 232
             $relational_table = $this->modelManager->create(
233
-                $model->getName() . '_' . $foreign->getName()
233
+                $model->getName().'_'.$foreign->getName()
234 234
             );
235 235
 
236 236
             $default_id = $this->config->isUsingUUID() ? '' : 0;
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
                 $rel_id = $this->createRecords($foreign);
250 250
                 $this->finalizeModel($foreign);
251 251
 
252
-                $model_id = $model->getName() . self::ID_SUFFIX;
253
-                $foreign_id = $foreign->getName() . self::ID_SUFFIX;
252
+                $model_id = $model->getName().self::ID_SUFFIX;
253
+                $foreign_id = $foreign->getName().self::ID_SUFFIX;
254 254
 
255 255
                 $relational_table = $this->modelManager->create(
256
-                    $model->getName() . '_' . $foreign->getName()
256
+                    $model->getName().'_'.$foreign->getName()
257 257
                 );
258 258
                 $relational_table->$model_id = $id;
259 259
                 $relational_table->$foreign_id = $rel_id;
Please login to merge, or discard this patch.
src/Manager/RecordManager.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function insert(Model $model): mixed
77 77
     {
78
-        return $this->executeInTransaction(function () use ($model) {
78
+        return $this->executeInTransaction(function() use ($model) {
79 79
             if ($this->config->isUsingUUID()) {
80 80
                 $model->set(self::ID_COLUMN, Uuid::uuid4()->toString());
81 81
             }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function update(Model $model): mixed
100 100
     {
101
-        return $this->executeInTransaction(function () use ($model) {
101
+        return $this->executeInTransaction(function() use ($model) {
102 102
             $this->connection->update(
103 103
                 $model->getName(),
104 104
                 $model->getSelfProperties(),
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function delete(Model $model): mixed
115 115
     {
116
-        return $this->executeInTransaction(function () use ($model) {
116
+        return $this->executeInTransaction(function() use ($model) {
117 117
             $this->connection->delete(
118 118
                 $model->getName(),
119 119
                 [self::ID_COLUMN => $model->getId()]
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getById(string $table, mixed $id): ?Model
129 129
     {
130
-        return $this->executeInTransaction(function () use ($table, $id) {
130
+        return $this->executeInTransaction(function() use ($table, $id) {
131 131
             return $this->createQueryBuilder()
132 132
                 ->select(self::ALL_COLUMNS)
133 133
                 ->from($table, self::DEFAULT_ALIAS)
134
-                ->where(self::DEFAULT_ALIAS . '.' . self::ID_COLUMN . ' = ?')
134
+                ->where(self::DEFAULT_ALIAS.'.'.self::ID_COLUMN.' = ?')
135 135
                 ->setParameter(0, $id)
136 136
                 ->first();
137 137
         });
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function getAll(string $tableName): Collection
144 144
     {
145
-        return $this->executeInTransaction(function () use ($tableName) {
145
+        return $this->executeInTransaction(function() use ($tableName) {
146 146
             return $this->createQueryBuilder()
147 147
                 ->select(self::ALL_COLUMNS)
148 148
                 ->from($tableName, self::DEFAULT_ALIAS)
Please login to merge, or discard this patch.