Passed
Branch feature/2.1-geodispersion-dev (1d61a8)
by Jonathan
61:21
created
src/Webtrees/Module/Sosa/Services/SosaStatisticsService.php 1 patch
Spacing   +58 added lines, -59 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function maxGeneration(): int
74 74
     {
75
-        return (int) DB::table('maj_sosa')
75
+        return (int)DB::table('maj_sosa')
76 76
             ->where('majs_gedcom_id', '=', $this->tree->id())
77 77
             ->where('majs_user_id', '=', $this->user->id())
78 78
             ->max('majs_gen');
@@ -149,8 +149,7 @@  discard block
 block discarded – undo
149 149
             ->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2')
150 150
             ->get()->first();
151 151
 
152
-        return $row->n == 0 ? 0 :
153
-            -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2));
152
+        return $row->n == 0 ? 0 : -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2));
154 153
     }
155 154
 
156 155
     /**
@@ -174,10 +173,10 @@  discard block
 block discarded – undo
174 173
 
175 174
         $statistics_by_gen = [];
176 175
         foreach ($stats_by_gen as $gen => $stats_gen) {
177
-            $statistics_by_gen[(int) $stats_gen->gen] = array(
178
-                'sosaCount'             =>  (int) $stats_gen->total_sosa,
179
-                'sosaTotalCount'        =>  (int) $cumul_stats_by_gen[$gen]->total_cumul,
180
-                'diffSosaTotalCount'    =>  (int) $cumul_stats_by_gen[$gen]->total_distinct_cumul,
176
+            $statistics_by_gen[(int)$stats_gen->gen] = array(
177
+                'sosaCount'             =>  (int)$stats_gen->total_sosa,
178
+                'sosaTotalCount'        =>  (int)$cumul_stats_by_gen[$gen]->total_cumul,
179
+                'diffSosaTotalCount'    =>  (int)$cumul_stats_by_gen[$gen]->total_distinct_cumul,
181 180
                 'firstBirth'            =>  $stats_gen->first_year,
182 181
                 'firstEstimatedBirth'   =>  $stats_gen->first_est_year,
183 182
                 'lastBirth'             =>  $stats_gen->last_year,
@@ -221,7 +220,7 @@  discard block
 block discarded – undo
221 220
             ->where('majs_user_id', '=', $this->user->id());
222 221
 
223 222
         return DB::table('maj_sosa')
224
-            ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void {
223
+            ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void {
225 224
                 $join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen')
226 225
                 ->where('majs_gedcom_id', '=', $this->tree->id())
227 226
                 ->where('majs_user_id', '=', $this->user->id());
@@ -258,37 +257,37 @@  discard block
 block discarded – undo
258 257
             ->select(['list_gen.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id'])
259 258
             ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen'])
260 259
             ->selectRaw(
261
-                '(CASE ' .
262
-                    ' WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL' .
263
-                    ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' .
264
-                    ' ELSE 0 ' .
265
-                ' END)' .
266
-                ' + (CASE ' .
267
-                    ' WHEN ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL' .
268
-                    ' THEN POWER(2, ' . $table_prefix . 'list_gen.majs_gen - ' . $table_prefix . 'sosa.majs_gen - 1)' .
269
-                    ' ELSE 0 ' .
260
+                '(CASE '.
261
+                    ' WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL'.
262
+                    ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'.
263
+                    ' ELSE 0 '.
264
+                ' END)'.
265
+                ' + (CASE '.
266
+                    ' WHEN '.$table_prefix.'sosa_mot.majs_i_id IS NULL'.
267
+                    ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'.
268
+                    ' ELSE 0 '.
270 269
                 ' END) contrib'
271 270
             )
272
-            ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void {
271
+            ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void {
273 272
                 $join->on('sosa.majs_gen', '<', 'list_gen.majs_gen')
274 273
                     ->where('majs_gedcom_id', '=', $this->tree->id())
275 274
                     ->where('majs_user_id', '=', $this->user->id());
276 275
             })
277
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void {
276
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
278 277
                 // Link to sosa's father
279
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
278
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
280 279
                     ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
281 280
                     ->where('sosa_fat.majs_user_id', '=', $this->user->id());
282 281
             })
283
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
282
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
284 283
                 // Link to sosa's mother
285
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
284
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
286 285
                     ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
287 286
                     ->where('sosa_mot.majs_user_id', '=', $this->user->id());
288 287
             })
289 288
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
290 289
             ->where('sosa.majs_user_id', '=', $this->user->id())
291
-            ->where(function (Builder $query): void {
290
+            ->where(function(Builder $query): void {
292 291
                 $query->whereNull('sosa_fat.majs_i_id')
293 292
                 ->orWhereNull('sosa_mot.majs_i_id');
294 293
             });
@@ -298,24 +297,24 @@  discard block
 block discarded – undo
298 297
          */
299 298
         $non_roots_ancestors = DB::table('maj_sosa AS sosa')
300 299
             ->select(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', 'sosa.majs_sosa'])
301
-            ->selectRaw('MAX(' . $table_prefix . 'sosa_anc.majs_sosa) - MIN(' . $table_prefix . 'sosa_anc.majs_sosa)' .
300
+            ->selectRaw('MAX('.$table_prefix.'sosa_anc.majs_sosa) - MIN('.$table_prefix.'sosa_anc.majs_sosa)'.
302 301
                 ' AS full_ancestors')
303
-            ->join('maj_sosa AS sosa_anc', function (JoinClause $join) use ($table_prefix): void {
302
+            ->join('maj_sosa AS sosa_anc', function(JoinClause $join) use ($table_prefix): void {
304 303
                 $join->on('sosa.majs_gen', '<', 'sosa_anc.majs_gen')
305
-                    ->whereRaw('FLOOR(' . $table_prefix . 'sosa_anc.majs_sosa / POWER(2, ' .
306
-                        $table_prefix . 'sosa_anc.majs_gen - ' . $table_prefix . 'sosa.majs_gen)) = ' .
307
-                        $table_prefix . 'sosa.majs_sosa')
304
+                    ->whereRaw('FLOOR('.$table_prefix.'sosa_anc.majs_sosa / POWER(2, '.
305
+                        $table_prefix.'sosa_anc.majs_gen - '.$table_prefix.'sosa.majs_gen)) = '.
306
+                        $table_prefix.'sosa.majs_sosa')
308 307
                     ->where('sosa_anc.majs_gedcom_id', '=', $this->tree->id())
309 308
                     ->where('sosa_anc.majs_user_id', '=', $this->user->id());
310 309
             })
311 310
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
312 311
             ->where('sosa.majs_user_id', '=', $this->user->id())
313
-            ->whereIn('sosa_anc.majs_i_id', function (Builder $query) use ($table_prefix): void {
312
+            ->whereIn('sosa_anc.majs_i_id', function(Builder $query) use ($table_prefix): void {
314 313
                 $query->from('maj_sosa AS sosa_gen')
315 314
                 ->select('sosa_gen.majs_i_id')->distinct()
316 315
                 ->where('sosa_gen.majs_gedcom_id', '=', $this->tree->id())
317 316
                 ->where('sosa_gen.majs_user_id', '=', $this->user->id())
318
-                ->whereRaw($table_prefix . 'sosa_gen.majs_gen = ' . $table_prefix . 'sosa.majs_gen');
317
+                ->whereRaw($table_prefix.'sosa_gen.majs_gen = '.$table_prefix.'sosa.majs_gen');
319 318
             })
320 319
             ->groupBy(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id',
321 320
                 'sosa.majs_sosa', 'sosa.majs_i_id']);
@@ -328,7 +327,7 @@  discard block
 block discarded – undo
328 327
             ->select(['sosa.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id'])
329 328
             ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen'])
330 329
             ->selectRaw('1 AS contrib')
331
-            ->leftJoinSub($non_roots_ancestors, 'nonroot', function (JoinClause $join): void {
330
+            ->leftJoinSub($non_roots_ancestors, 'nonroot', function(JoinClause $join): void {
332 331
                 $join->on('sosa.majs_gen', '=', 'nonroot.majs_gen')
333 332
                     ->on('sosa.majs_sosa', '=', 'nonroot.majs_sosa')
334 333
                     ->where('nonroot.full_ancestors', '>', 0)
@@ -346,9 +345,9 @@  discard block
 block discarded – undo
346 345
             ->fromSub($root_ancestors_contributions->unionAll($known_ancestors_contributions), 'sosa_contribs')
347 346
             ->select(['sosa_contribs.gen', 'sosa_contribs.majs_gedcom_id', 'sosa_contribs.majs_user_id'])
348 347
             ->addSelect(['sosa_contribs.majs_i_id', 'sosa_contribs.contrib'])
349
-            ->selectRaw('COUNT(' . $table_prefix . 'sosa_contribs.majs_i_id) * ' .
350
-                $table_prefix . 'sosa_contribs.contrib AS totalContrib')
351
-            ->leftJoin('maj_sosa AS sosa_low', function (JoinClause $join): void {
348
+            ->selectRaw('COUNT('.$table_prefix.'sosa_contribs.majs_i_id) * '.
349
+                $table_prefix.'sosa_contribs.contrib AS totalContrib')
350
+            ->leftJoin('maj_sosa AS sosa_low', function(JoinClause $join): void {
352 351
                 $join->on('sosa_low.majs_gen', '<', 'sosa_contribs.majs_gen')
353 352
                     ->on('sosa_low.majs_i_id', '=', 'sosa_contribs.majs_i_id')
354 353
                     ->where('sosa_low.majs_gedcom_id', '=', $this->tree->id())
@@ -369,9 +368,9 @@  discard block
 block discarded – undo
369 368
 
370 369
         $pedi_collapse_by_gen = [];
371 370
         foreach ($pedi_collapse_coll as $collapse_gen) {
372
-            $pedi_collapse_by_gen[(int) $collapse_gen->gen] = array(
373
-                'pedi_collapse_roots'   =>  (float) $collapse_gen->pedi_collapse_roots,
374
-                'pedi_collapse_xgen'   =>  (float) $collapse_gen->pedi_collapse_xgen
371
+            $pedi_collapse_by_gen[(int)$collapse_gen->gen] = array(
372
+                'pedi_collapse_roots'   =>  (float)$collapse_gen->pedi_collapse_roots,
373
+                'pedi_collapse_xgen'   =>  (float)$collapse_gen->pedi_collapse_xgen
375 374
             );
376 375
         }
377 376
         return $pedi_collapse_by_gen;
@@ -399,26 +398,26 @@  discard block
 block discarded – undo
399 398
     {
400 399
         $table_prefix = DB::connection()->getTablePrefix();
401 400
         $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa')
402
-            ->selectRaw($table_prefix . 'sosa.majs_gen - ? AS majs_gen_norm', [$gen])
403
-            ->selectRaw('FLOOR(((' . $table_prefix . 'sosa.majs_sosa / POW(2, ' . $table_prefix . 'sosa.majs_gen -1 )) - 1) * POWER(2, ? - 1)) + POWER(2, ? - 1) AS root_ancestor', [$gen, $gen])   //@phpcs:ignore Generic.Files.LineLength.TooLong
404
-            ->selectRaw('SUM(CASE WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL AND ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL THEN 1 ELSE 0 END) AS full_root_count')  //@phpcs:ignore Generic.Files.LineLength.TooLong
405
-            ->selectRaw('SUM(CASE WHEN ' . $table_prefix . 'sosa_fat.majs_i_id IS NULL AND ' . $table_prefix . 'sosa_mot.majs_i_id IS NULL THEN 0 ELSE 1 END) As semi_root_count')  //@phpcs:ignore Generic.Files.LineLength.TooLong
406
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void {
401
+            ->selectRaw($table_prefix.'sosa.majs_gen - ? AS majs_gen_norm', [$gen])
402
+            ->selectRaw('FLOOR((('.$table_prefix.'sosa.majs_sosa / POW(2, '.$table_prefix.'sosa.majs_gen -1 )) - 1) * POWER(2, ? - 1)) + POWER(2, ? - 1) AS root_ancestor', [$gen, $gen])   //@phpcs:ignore Generic.Files.LineLength.TooLong
403
+            ->selectRaw('SUM(CASE WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL AND '.$table_prefix.'sosa_mot.majs_i_id IS NULL THEN 1 ELSE 0 END) AS full_root_count')  //@phpcs:ignore Generic.Files.LineLength.TooLong
404
+            ->selectRaw('SUM(CASE WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL AND '.$table_prefix.'sosa_mot.majs_i_id IS NULL THEN 0 ELSE 1 END) As semi_root_count')  //@phpcs:ignore Generic.Files.LineLength.TooLong
405
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
407 406
                 // Link to sosa's father
408
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
407
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
409 408
                 ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
410 409
                 ->where('sosa_fat.majs_user_id', '=', $this->user->id());
411 410
             })
412
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
411
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
413 412
                 // Link to sosa's mother
414
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
413
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
415 414
                 ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
416 415
                 ->where('sosa_mot.majs_user_id', '=', $this->user->id());
417 416
             })
418 417
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
419 418
             ->where('sosa.majs_user_id', '=', $this->user->id())
420 419
             ->where('sosa.majs_gen', '>=', $gen)
421
-            ->where(function (Builder $query): void {
420
+            ->where(function(Builder $query): void {
422 421
                 $query->whereNull('sosa_fat.majs_i_id')
423 422
                     ->orWhereNull('sosa_mot.majs_i_id');
424 423
             })
@@ -427,11 +426,11 @@  discard block
 block discarded – undo
427 426
         return DB::table('maj_sosa AS sosa_list')
428 427
             ->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id'])
429 428
             ->selectRaw('1 + SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))) AS mean_gen_depth')  //@phpcs:ignore Generic.Files.LineLength.TooLong
430
-            ->selectRaw(' SQRT(' .
431
-                '   SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm)))' .     //@phpcs:ignore Generic.Files.LineLength.TooLong
432
-                '   - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))), 2)' .       //@phpcs:ignore Generic.Files.LineLength.TooLong
429
+            ->selectRaw(' SQRT('.
430
+                '   SUM(POWER(majs_gen_norm, 2) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm)))'.//@phpcs:ignore Generic.Files.LineLength.TooLong
431
+                '   - POWER( SUM( (majs_gen_norm) * ( 2 * full_root_count + semi_root_count) /  (2 * POWER(2, majs_gen_norm))), 2)'.//@phpcs:ignore Generic.Files.LineLength.TooLong
433 432
                 ' ) AS stddev_gen_depth')
434
-            ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function (JoinClause $join): void {
433
+            ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join): void {
435 434
                 $join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor')
436 435
                     ->where('sosa_list.majs_gedcom_id', '=', $this->tree->id())
437 436
                     ->where('sosa_list.majs_user_id', '=', $this->user->id());
@@ -460,16 +459,16 @@  discard block
 block discarded – undo
460 459
         $table_prefix = DB::connection()->getTablePrefix();
461 460
         $multiple_ancestors = DB::table('maj_sosa AS sosa')
462 461
             ->select('sosa.majs_i_id AS sosa_i_id')
463
-            ->selectRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) AS sosa_count')
464
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void {
462
+            ->selectRaw('COUNT('.$table_prefix.'sosa.majs_sosa) AS sosa_count')
463
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
465 464
                 // Link to sosa's father
466
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
465
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
467 466
                     ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
468 467
                     ->where('sosa_fat.majs_user_id', '=', $this->user->id());
469 468
             })
470
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
469
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
471 470
                 // Link to sosa's mother
472
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
471
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
473 472
                 ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
474 473
                 ->where('sosa_mot.majs_user_id', '=', $this->user->id());
475 474
             })
@@ -478,15 +477,15 @@  discard block
 block discarded – undo
478 477
             ->whereNull('sosa_fat.majs_sosa')   // We keep only root individuals, i.e. those with no father or mother
479 478
             ->whereNull('sosa_mot.majs_sosa')
480 479
             ->groupBy('sosa.majs_i_id')
481
-            ->havingRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) > 1')    // Limit to the duplicate sosas.
482
-            ->orderByRaw('COUNT(' . $table_prefix . 'sosa.majs_sosa) DESC, MIN(' . $table_prefix . 'sosa.majs_sosa) ASC')   //@phpcs:ignore Generic.Files.LineLength.TooLong
480
+            ->havingRaw('COUNT('.$table_prefix.'sosa.majs_sosa) > 1')    // Limit to the duplicate sosas.
481
+            ->orderByRaw('COUNT('.$table_prefix.'sosa.majs_sosa) DESC, MIN('.$table_prefix.'sosa.majs_sosa) ASC')   //@phpcs:ignore Generic.Files.LineLength.TooLong
483 482
             ->limit($limit + 1)     // We want to select one more than required, for ties
484 483
             ->get();
485 484
 
486 485
         if ($multiple_ancestors->count() > $limit) {
487 486
             $last_count = $multiple_ancestors->last()->sosa_count;
488
-            $multiple_ancestors = $multiple_ancestors->reject(function (stdClass $element) use ($last_count): bool {
489
-                return $element->sosa_count ==  $last_count;
487
+            $multiple_ancestors = $multiple_ancestors->reject(function(stdClass $element) use ($last_count): bool {
488
+                return $element->sosa_count == $last_count;
490 489
             });
491 490
         }
492 491
         return $multiple_ancestors;
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaModule.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     // How to update the database schema for this module
71 71
     private const SCHEMA_TARGET_VERSION   = 3;
72 72
     private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
73
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
73
+    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema';
74 74
 /**
75 75
      * {@inheritDoc}
76 76
      * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function loadRoutes(Map $router): void
112 112
     {
113
-        $router->attach('', '', static function (Map $router): void {
113
+        $router->attach('', '', static function(Map $router): void {
114 114
 
115
-            $router->attach('', '/module-maj/sosa', static function (Map $router): void {
115
+            $router->attach('', '/module-maj/sosa', static function(Map $router): void {
116 116
 
117
-                $router->attach('', '/list', static function (Map $router): void {
117
+                $router->attach('', '/list', static function(Map $router): void {
118 118
 
119 119
                     $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class);
120
-                    $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class);    //phpcs:ignore Generic.Files.LineLength.TooLong
121
-                    $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class);   //phpcs:ignore Generic.Files.LineLength.TooLong
120
+                    $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong
121
+                    $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong
122 122
                     $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class);
123 123
                 });
124 124
 
125
-                $router->attach('', '/statistics/{tree}', static function (Map $router): void {
125
+                $router->attach('', '/statistics/{tree}', static function(Map $router): void {
126 126
 
127 127
                     $router->get(SosaStatistics::class, '', SosaStatistics::class);
128 128
                     $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class);
129 129
                 });
130 130
 
131
-                $router->attach('', '/config/{tree}', static function (Map $router): void {
131
+                $router->attach('', '/config/{tree}', static function(Map $router): void {
132 132
 
133 133
                     $router->get(SosaConfig::class, '', SosaConfig::class);
134 134
                     $router->post(SosaConfigAction::class, '', SosaConfigAction::class);
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public function headContent(): string
229 229
     {
230
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
230
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
231 231
     }
232 232
 
233 233
     /**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function bodyContent(): string
238 238
     {
239
-        return '<script src="' . $this->assetUrl('js/sosa.min.js') . '"></script>';
239
+        return '<script src="'.$this->assetUrl('js/sosa.min.js').'"></script>';
240 240
     }
241 241
 
242 242
     /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
         $individual = Registry::individualFactory()->make($xref, $tree);
254 254
 
255
-        return view($this->name() . '::sidebar/title', [
255
+        return view($this->name().'::sidebar/title', [
256 256
             'module_name'   =>  $this->name(),
257 257
             'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($tree, $user, $individual)
258 258
         ]);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         $sosa_root = Registry::individualFactory()->make($sosa_root_xref, $individual->tree());
269 269
         $user = Auth::check() ? Auth::user() : new DefaultUser();
270 270
 
271
-        return view($this->name() . '::sidebar/content', [
271
+        return view($this->name().'::sidebar/content', [
272 272
             'sosa_ancestor' =>  $individual,
273 273
             'sosa_root'     =>  $sosa_root,
274 274
             'sosa_numbers'  =>  app(SosaRecordsService::class)->sosaNumbers($individual->tree(), $user, $individual)
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/GeoAnalysis/GeoAnalysisResult.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function addPlace(GeoAnalysisPlace $place): void
80 80
     {
81
-        if($place->isKnown()) {
81
+        if ($place->isKnown()) {
82 82
             /** @var GeoAnalysisResultItem $item */
83 83
             $item = $this->places->get($place->key(), new GeoAnalysisResultItem($place));
84 84
             $this->places->put($item->key(), $item->increment());
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         /** @var GeoAnalysisResultItem|null $item */
98 98
         $item = $this->places->get($place->key());
99
-        if($item !== null) {
99
+        if ($item !== null) {
100 100
             $item->place()->exclude();
101 101
         }
102 102
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     public function merge(GeoAnalysisResult $other): self
135 135
     {
136 136
         $this->places->each(function(GeoAnalysisResultItem $item) use ($other) : void {
137
-            if($other->places->has($item->key())) {
137
+            if ($other->places->has($item->key())) {
138 138
                 $item->place()->exclude(
139 139
                     $item->place()->isExcluded() 
140 140
                     && $other->places->get($item->key())->place()->isExcluded()
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         });
144 144
         
145 145
         $other->places->each(function(GeoAnalysisResultItem $item): void {
146
-            if(!$this->places->has($item->key())) {
146
+            if (!$this->places->has($item->key())) {
147 147
                 $this->addPlace($item->place());
148 148
             }
149 149
         });
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      */
214 214
     public function knownPlaces(bool $exclude_other = false): Collection
215 215
     {
216
-        if($exclude_other) {
216
+        if ($exclude_other) {
217 217
             return $this->places->reject(fn(GeoAnalysisResultItem $item): bool => $item->place()->isExcluded());
218 218
         }
219 219
         return $this->places;
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
     public function sortedKnownPlaces(bool $exclude_other = false): Collection
230 230
     {
231 231
         return $this->knownPlaces($exclude_other)->sortBy([
232
-            fn (GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => $b->count() <=> $a->count(),
233
-            fn (GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => 
232
+            fn(GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => $b->count() <=> $a->count(),
233
+            fn(GeoAnalysisResultItem $a, GeoAnalysisResultItem $b): int => 
234 234
                 I18N::comparator()($a->place()->place()->gedcomName(), $b->place()->place()->gedcomName())
235 235
         ]);
236 236
     }
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/GeoAnalysis/GeoAnalysisResults.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function addCategory(string $description, int $order): void
91 91
     {
92
-        if(!$this->detailed->has($description)) {
92
+        if (!$this->detailed->has($description)) {
93 93
             $this->detailed->put($description, new GeoAnalysisResult($description, $order));
94 94
         }
95 95
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function addPlaceInCreatedCategory(string $category_name, GeoAnalysisPlace $place): void
104 104
     {
105
-        if($this->detailed->has($category_name)) {
105
+        if ($this->detailed->has($category_name)) {
106 106
             $this->detailed->get($category_name)->addPlace($place);
107 107
         }
108 108
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function addPlaceInCategory(string $category_name, int $category_order, GeoAnalysisPlace $place): void
117 117
     {
118
-        if(!$this->detailed->has($category_name)) {
118
+        if (!$this->detailed->has($category_name)) {
119 119
             $this->addCategory($category_name, $category_order);
120 120
         }
121 121
         $this->addPlaceInCreatedCategory($category_name, $place);
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/GeoAnalysis/GeoAnalysisPlace.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,10 +64,10 @@
 block discarded – undo
64 64
      */
65 65
     private function extractPlace(?Place $place, int $depth, bool $strict_depth): ?Place
66 66
     {
67
-        if($place === null) return null;
68
-        if(mb_strlen($place->gedcomName()) === 0) return null;
67
+        if ($place === null) return null;
68
+        if (mb_strlen($place->gedcomName()) === 0) return null;
69 69
         $parts = $place->lastParts($depth);
70
-        if($strict_depth && $parts->count() !== $depth) return new Place(self::INVALID_PLACE, $place->tree());
70
+        if ($strict_depth && $parts->count() !== $depth) return new Place(self::INVALID_PLACE, $place->tree());
71 71
         return new Place($parts->implode(', '), $place->tree());
72 72
     }
73 73
     
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/Maps/SimpleFilesystemMap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,11 +74,11 @@
 block discarded – undo
74 74
         $reader = new GeoJSONReader();
75 75
         try {
76 76
             $feature_collection = $reader->read($this->filesystem->read($this->path));
77
-            if($feature_collection instanceof FeatureCollection) {
77
+            if ($feature_collection instanceof FeatureCollection) {
78 78
                 return $feature_collection->getFeatures();
79 79
             }
80 80
         }
81
-        catch(Throwable $ex) { }
81
+        catch (Throwable $ex) { }
82 82
         return [];
83 83
     }
84 84
     
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/Config/GenericPlaceMapperConfig.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,10 +91,10 @@
 block discarded – undo
91 91
      */
92 92
     public function jsonDeserialize($config): self
93 93
     {
94
-        if(is_string($config)) {
94
+        if (is_string($config)) {
95 95
             return $this->jsonDeserialize(json_decode($config));
96 96
         }
97
-        if(is_array($config)) {
97
+        if (is_array($config)) {
98 98
             return $this->setConfig($config);
99 99
         }
100 100
         return $this;
Please login to merge, or discard this patch.
src/Webtrees/Common/GeoDispersion/Config/MapColorsConfig.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,10 +64,10 @@
 block discarded – undo
64 64
     public function jsonSerialize()
65 65
     {
66 66
         return [
67
-            'default'   => (string) $this->defaultColor()->toHex(),
68
-            'stroke'    => (string) $this->strokeColor()->toHex(),
69
-            'maxvalue'  => (string) $this->maxValueColor()->toHex(),
70
-            'hover'     => (string) $this->hoverColor()->toHex(),
67
+            'default'   => (string)$this->defaultColor()->toHex(),
68
+            'stroke'    => (string)$this->strokeColor()->toHex(),
69
+            'maxvalue'  => (string)$this->maxValueColor()->toHex(),
70
+            'hover'     => (string)$this->hoverColor()->toHex(),
71 71
         ];
72 72
     }
73 73
 
Please login to merge, or discard this patch.