Passed
Branch feature/2.0 (9789a8)
by Jonathan
14:17
created
src/Webtrees/Module/AdminTasks/Http/RequestHandlers/TaskEditPage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
68 68
         }
69 69
 
70
-        $task_sched_id = (int) $request->getAttribute('task');
70
+        $task_sched_id = (int)$request->getAttribute('task');
71 71
         $task_schedule = $this->taskschedules_service->find($task_sched_id);
72 72
 
73 73
         if ($task_schedule === null) {
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
         $has_task_config = $task instanceof ConfigurableTaskInterface;
84 84
         /** @var TaskInterface&ConfigurableTaskInterface $task */
85 85
 
86
-        return $this->viewResponse($this->module->name() . '::admin/tasks-edit', [
86
+        return $this->viewResponse($this->module->name().'::admin/tasks-edit', [
87 87
             'module'            =>  $this->module,
88
-            'title'             =>  I18N::translate('Edit the administrative task') . ' - ' . $task->name(),
88
+            'title'             =>  I18N::translate('Edit the administrative task').' - '.$task->name(),
89 89
             'task_schedule'     =>  $task_schedule,
90 90
             'task'              =>  $task,
91 91
             'has_task_config'   =>  $has_task_config,
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaRecordsService.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
     {
110 110
         $table_prefix = DB::connection()->getTablePrefix();
111 111
         return DB::table('families')
112
-            ->join('maj_sosa AS sosa_husb', function (JoinClause $join) use ($tree, $user): void {
112
+            ->join('maj_sosa AS sosa_husb', function(JoinClause $join) use ($tree, $user): void {
113 113
                 // Link to family husband
114 114
                 $join->on('families.f_file', '=', 'sosa_husb.majs_gedcom_id')
115 115
                     ->on('families.f_husb', '=', 'sosa_husb.majs_i_id')
116 116
                     ->where('sosa_husb.majs_gedcom_id', '=', $tree->id())
117 117
                     ->where('sosa_husb.majs_user_id', '=', $user->id());
118 118
             })
119
-            ->join('maj_sosa AS sosa_wife', function (JoinClause $join) use ($tree, $user): void {
119
+            ->join('maj_sosa AS sosa_wife', function(JoinClause $join) use ($tree, $user): void {
120 120
                 // Link to family husband
121 121
                 $join->on('families.f_file', '=', 'sosa_wife.majs_gedcom_id')
122 122
                 ->on('families.f_wife', '=', 'sosa_wife.majs_i_id')
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
             })
126 126
             ->select(['sosa_husb.majs_sosa', 'families.f_id'])
127 127
             ->where('sosa_husb.majs_gen', '=', $gen)
128
-            ->whereRaw($table_prefix . 'sosa_husb.majs_sosa + 1 = ' . $table_prefix . 'sosa_wife.majs_sosa')
128
+            ->whereRaw($table_prefix.'sosa_husb.majs_sosa + 1 = '.$table_prefix.'sosa_wife.majs_sosa')
129 129
             ->orderBy('sosa_husb.majs_sosa')
130 130
             ->get();
131 131
     }
@@ -148,28 +148,28 @@  discard block
 block discarded – undo
148 148
         $table_prefix = DB::connection()->getTablePrefix();
149 149
         return DB::table('maj_sosa AS sosa')
150 150
             ->select(['sosa.majs_i_id', 'sosa_fat.majs_i_id AS majs_fat_id', 'sosa_mot.majs_i_id AS majs_mot_id'])
151
-            ->selectRaw('MIN(' . $table_prefix . 'sosa.majs_sosa) AS majs_sosa')
152
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
151
+            ->selectRaw('MIN('.$table_prefix.'sosa.majs_sosa) AS majs_sosa')
152
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($tree, $user, $table_prefix): void {
153 153
                 // Link to sosa's father
154
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
154
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
155 155
                     ->where('sosa_fat.majs_gedcom_id', '=', $tree->id())
156 156
                     ->where('sosa_fat.majs_user_id', '=', $user->id());
157 157
             })
158
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($tree, $user, $table_prefix): void {
158
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($tree, $user, $table_prefix): void {
159 159
                 // Link to sosa's mother
160
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
160
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
161 161
                     ->where('sosa_mot.majs_gedcom_id', '=', $tree->id())
162 162
                     ->where('sosa_mot.majs_user_id', '=', $user->id());
163 163
             })
164 164
             ->where('sosa.majs_gedcom_id', '=', $tree->id())
165 165
             ->where('sosa.majs_user_id', '=', $user->id())
166 166
             ->where('sosa.majs_gen', '=', $gen - 1)
167
-            ->where(function (Builder $query): void {
167
+            ->where(function(Builder $query): void {
168 168
                 $query->whereNull('sosa_fat.majs_i_id')
169 169
                     ->orWhereNull('sosa_mot.majs_i_id');
170 170
             })
171 171
             ->groupBy('sosa.majs_i_id', 'sosa_fat.majs_i_id', 'sosa_mot.majs_i_id')
172
-            ->orderByRaw('MIN(' . $table_prefix . 'sosa.majs_sosa)')
172
+            ->orderByRaw('MIN('.$table_prefix.'sosa.majs_sosa)')
173 173
             ->get();
174 174
     }
175 175
 
@@ -220,28 +220,28 @@  discard block
 block discarded – undo
220 220
         $bindings_placeholders = $bindings_values = [];
221 221
         foreach ($sosa_records as $i => $row) {
222 222
             $gen = $this->generation($row['sosa']);
223
-            if ($gen <=  $this->maxSystemGenerations()) {
223
+            if ($gen <= $this->maxSystemGenerations()) {
224 224
                 if ($mass_update) {
225
-                    $bindings_placeholders[] = '(:tree_id' . $i . ', :user_id' . $i . ', :sosa' . $i . ',' .
226
-                        ' :indi_id' . $i . ', :gen' . $i . ',' .
227
-                        ' :byear' . $i . ', :byearest' . $i . ', :dyear' . $i . ', :dyearest' . $i . ')';
225
+                    $bindings_placeholders[] = '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.','.
226
+                        ' :indi_id'.$i.', :gen'.$i.','.
227
+                        ' :byear'.$i.', :byearest'.$i.', :dyear'.$i.', :dyearest'.$i.')';
228 228
                     $bindings_values = array_merge(
229 229
                         $bindings_values,
230 230
                         [
231
-                            'tree_id' . $i => $tree->id(),
232
-                            'user_id' . $i => $user->id(),
233
-                            'sosa' . $i => $row['sosa'],
234
-                            'indi_id' . $i => $row['indi'],
235
-                            'gen' . $i => $gen,
236
-                            'byear' . $i => $row['birth_year'],
237
-                            'byearest' . $i => $row['birth_year_est'],
238
-                            'dyear' . $i => $row['death_year'],
239
-                            'dyearest' . $i => $row['death_year_est']
231
+                            'tree_id'.$i => $tree->id(),
232
+                            'user_id'.$i => $user->id(),
233
+                            'sosa'.$i => $row['sosa'],
234
+                            'indi_id'.$i => $row['indi'],
235
+                            'gen'.$i => $gen,
236
+                            'byear'.$i => $row['birth_year'],
237
+                            'byearest'.$i => $row['birth_year_est'],
238
+                            'dyear'.$i => $row['death_year'],
239
+                            'dyearest'.$i => $row['death_year_est']
240 240
                         ]
241 241
                     );
242 242
                 } else {
243 243
                     DB::table('maj_sosa')->updateOrInsert(
244
-                        [ 'majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
244
+                        ['majs_gedcom_id' => $tree->id(), 'majs_user_id' => $user->id(), 'majs_sosa' => $row['sosa']],
245 245
                         [
246 246
                             'majs_i_id' => $row['indi'],
247 247
                             'majs_gen' => $gen,
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 
258 258
         if ($mass_update) {
259 259
             DB::connection()->statement(
260
-                'INSERT INTO `' . DB::connection()->getTablePrefix() . 'maj_sosa`' .
261
-                ' (majs_gedcom_id, majs_user_id, majs_sosa,' .
262
-                '   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)' .
263
-                ' VALUES ' . implode(',', $bindings_placeholders) .
264
-                ' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),' .
265
-                '   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),' .
260
+                'INSERT INTO `'.DB::connection()->getTablePrefix().'maj_sosa`'.
261
+                ' (majs_gedcom_id, majs_user_id, majs_sosa,'.
262
+                '   majs_i_id, majs_gen, majs_birth_year, majs_birth_year_est, majs_death_year, majs_death_year_est)'.
263
+                ' VALUES '.implode(',', $bindings_placeholders).
264
+                ' ON DUPLICATE KEY UPDATE majs_i_id = VALUES(majs_i_id), majs_gen = VALUES(majs_gen),'.
265
+                '   majs_birth_year = VALUES(majs_birth_year), majs_birth_year_est = VALUES(majs_birth_year_est),'.
266 266
                 '   majs_death_year = VALUES(majs_death_year), majs_death_year_est = VALUES(majs_death_year_est)',
267 267
                 $bindings_values
268 268
             );
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaStatisticsService.php 1 patch
Spacing   +58 added lines, -59 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function maxGeneration(): int
73 73
     {
74
-        return (int) DB::table('maj_sosa')
74
+        return (int)DB::table('maj_sosa')
75 75
             ->where('majs_gedcom_id', '=', $this->tree->id())
76 76
             ->where('majs_user_id', '=', $this->user->id())
77 77
             ->max('majs_gen');
@@ -148,8 +148,7 @@  discard block
 block discarded – undo
148 148
             ->selectRaw('SUM(majs_gen * majs_gen) AS sum_x2')
149 149
             ->get()->first();
150 150
 
151
-        return $row->n == 0 ? 0 :
152
-            -($row->n * $row->sum_xy - $row->sum_x * $row->sum_y) / ($row->n * $row->sum_x2 - pow($row->sum_x, 2));
151
+        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));
153 152
     }
154 153
 
155 154
     /**
@@ -173,10 +172,10 @@  discard block
 block discarded – undo
173 172
 
174 173
         $statistics_by_gen = [];
175 174
         foreach ($stats_by_gen as $gen => $stats_gen) {
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,
175
+            $statistics_by_gen[(int)$stats_gen->gen] = array(
176
+                'sosaCount'             =>  (int)$stats_gen->total_sosa,
177
+                'sosaTotalCount'        =>  (int)$cumul_stats_by_gen[$gen]->total_cumul,
178
+                'diffSosaTotalCount'    =>  (int)$cumul_stats_by_gen[$gen]->total_distinct_cumul,
180 179
                 'firstBirth'            =>  $stats_gen->first_year,
181 180
                 'firstEstimatedBirth'   =>  $stats_gen->first_est_year,
182 181
                 'lastBirth'             =>  $stats_gen->last_year,
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
             ->where('majs_user_id', '=', $this->user->id());
221 220
 
222 221
         return DB::table('maj_sosa')
223
-            ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void {
222
+            ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void {
224 223
                 $join->on('maj_sosa.majs_gen', '<=', 'list_gen.majs_gen')
225 224
                 ->where('majs_gedcom_id', '=', $this->tree->id())
226 225
                 ->where('majs_user_id', '=', $this->user->id());
@@ -257,37 +256,37 @@  discard block
 block discarded – undo
257 256
             ->select(['list_gen.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id'])
258 257
             ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen'])
259 258
             ->selectRaw(
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 ' .
259
+                '(CASE '.
260
+                    ' WHEN '.$table_prefix.'sosa_fat.majs_i_id IS NULL'.
261
+                    ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'.
262
+                    ' ELSE 0 '.
263
+                ' END)'.
264
+                ' + (CASE '.
265
+                    ' WHEN '.$table_prefix.'sosa_mot.majs_i_id IS NULL'.
266
+                    ' THEN POWER(2, '.$table_prefix.'list_gen.majs_gen - '.$table_prefix.'sosa.majs_gen - 1)'.
267
+                    ' ELSE 0 '.
269 268
                 ' END) contrib'
270 269
             )
271
-            ->joinSub($list_gen, 'list_gen', function (JoinClause $join): void {
270
+            ->joinSub($list_gen, 'list_gen', function(JoinClause $join): void {
272 271
                 $join->on('sosa.majs_gen', '<', 'list_gen.majs_gen')
273 272
                     ->where('majs_gedcom_id', '=', $this->tree->id())
274 273
                     ->where('majs_user_id', '=', $this->user->id());
275 274
             })
276
-            ->leftJoin('maj_sosa AS sosa_fat', function (JoinClause $join) use ($table_prefix): void {
275
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
277 276
                 // Link to sosa's father
278
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
277
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
279 278
                     ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
280 279
                     ->where('sosa_fat.majs_user_id', '=', $this->user->id());
281 280
             })
282
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
281
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
283 282
                 // Link to sosa's mother
284
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
283
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
285 284
                     ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
286 285
                     ->where('sosa_mot.majs_user_id', '=', $this->user->id());
287 286
             })
288 287
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
289 288
             ->where('sosa.majs_user_id', '=', $this->user->id())
290
-            ->where(function (Builder $query): void {
289
+            ->where(function(Builder $query): void {
291 290
                 $query->whereNull('sosa_fat.majs_i_id')
292 291
                 ->orWhereNull('sosa_mot.majs_i_id');
293 292
             });
@@ -297,24 +296,24 @@  discard block
 block discarded – undo
297 296
          */
298 297
         $non_roots_ancestors = DB::table('maj_sosa AS sosa')
299 298
             ->select(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id', 'sosa.majs_sosa'])
300
-            ->selectRaw('MAX(' . $table_prefix . 'sosa_anc.majs_sosa) - MIN(' . $table_prefix . 'sosa_anc.majs_sosa)' .
299
+            ->selectRaw('MAX('.$table_prefix.'sosa_anc.majs_sosa) - MIN('.$table_prefix.'sosa_anc.majs_sosa)'.
301 300
                 ' AS full_ancestors')
302
-            ->join('maj_sosa AS sosa_anc', function (JoinClause $join) use ($table_prefix): void {
301
+            ->join('maj_sosa AS sosa_anc', function(JoinClause $join) use ($table_prefix): void {
303 302
                 $join->on('sosa.majs_gen', '<', 'sosa_anc.majs_gen')
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')
303
+                    ->whereRaw('FLOOR('.$table_prefix.'sosa_anc.majs_sosa / POWER(2, '.
304
+                        $table_prefix.'sosa_anc.majs_gen - '.$table_prefix.'sosa.majs_gen)) = '.
305
+                        $table_prefix.'sosa.majs_sosa')
307 306
                     ->where('sosa_anc.majs_gedcom_id', '=', $this->tree->id())
308 307
                     ->where('sosa_anc.majs_user_id', '=', $this->user->id());
309 308
             })
310 309
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
311 310
             ->where('sosa.majs_user_id', '=', $this->user->id())
312
-            ->whereIn('sosa_anc.majs_i_id', function (Builder $query) use ($table_prefix): void {
311
+            ->whereIn('sosa_anc.majs_i_id', function(Builder $query) use ($table_prefix): void {
313 312
                 $query->from('maj_sosa AS sosa_gen')
314 313
                 ->select('sosa_gen.majs_i_id')->distinct()
315 314
                 ->where('sosa_gen.majs_gedcom_id', '=', $this->tree->id())
316 315
                 ->where('sosa_gen.majs_user_id', '=', $this->user->id())
317
-                ->whereRaw($table_prefix . 'sosa_gen.majs_gen = ' . $table_prefix . 'sosa.majs_gen');
316
+                ->whereRaw($table_prefix.'sosa_gen.majs_gen = '.$table_prefix.'sosa.majs_gen');
318 317
             })
319 318
             ->groupBy(['sosa.majs_gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id',
320 319
                 'sosa.majs_sosa', 'sosa.majs_i_id']);
@@ -327,7 +326,7 @@  discard block
 block discarded – undo
327 326
             ->select(['sosa.majs_gen AS gen', 'sosa.majs_gedcom_id', 'sosa.majs_user_id'])
328 327
             ->addSelect(['sosa.majs_i_id', 'sosa.majs_gen'])
329 328
             ->selectRaw('1 AS contrib')
330
-            ->leftJoinSub($non_roots_ancestors, 'nonroot', function (JoinClause $join): void {
329
+            ->leftJoinSub($non_roots_ancestors, 'nonroot', function(JoinClause $join): void {
331 330
                 $join->on('sosa.majs_gen', '=', 'nonroot.majs_gen')
332 331
                     ->on('sosa.majs_sosa', '=', 'nonroot.majs_sosa')
333 332
                     ->where('nonroot.full_ancestors', '>', 0)
@@ -345,9 +344,9 @@  discard block
 block discarded – undo
345 344
             ->fromSub($root_ancestors_contributions->unionAll($known_ancestors_contributions), 'sosa_contribs')
346 345
             ->select(['sosa_contribs.gen', 'sosa_contribs.majs_gedcom_id', 'sosa_contribs.majs_user_id'])
347 346
             ->addSelect(['sosa_contribs.majs_i_id', 'sosa_contribs.contrib'])
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 {
347
+            ->selectRaw('COUNT('.$table_prefix.'sosa_contribs.majs_i_id) * '.
348
+                $table_prefix.'sosa_contribs.contrib AS totalContrib')
349
+            ->leftJoin('maj_sosa AS sosa_low', function(JoinClause $join): void {
351 350
                 $join->on('sosa_low.majs_gen', '<', 'sosa_contribs.majs_gen')
352 351
                     ->on('sosa_low.majs_i_id', '=', 'sosa_contribs.majs_i_id')
353 352
                     ->where('sosa_low.majs_gedcom_id', '=', $this->tree->id())
@@ -368,9 +367,9 @@  discard block
 block discarded – undo
368 367
 
369 368
         $pedi_collapse_by_gen = [];
370 369
         foreach ($pedi_collapse_coll as $collapse_gen) {
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
370
+            $pedi_collapse_by_gen[(int)$collapse_gen->gen] = array(
371
+                'pedi_collapse_roots'   =>  (float)$collapse_gen->pedi_collapse_roots,
372
+                'pedi_collapse_xgen'   =>  (float)$collapse_gen->pedi_collapse_xgen
374 373
             );
375 374
         }
376 375
         return $pedi_collapse_by_gen;
@@ -398,26 +397,26 @@  discard block
 block discarded – undo
398 397
     {
399 398
         $table_prefix = DB::connection()->getTablePrefix();
400 399
         $missing_ancestors_by_gen = DB::table('maj_sosa AS sosa')
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 {
400
+            ->selectRaw($table_prefix.'sosa.majs_gen - ? AS majs_gen_norm', [$gen])
401
+            ->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
402
+            ->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
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 0 ELSE 1 END) As semi_root_count')  //@phpcs:ignore Generic.Files.LineLength.TooLong
404
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
406 405
                 // Link to sosa's father
407
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
406
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
408 407
                 ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
409 408
                 ->where('sosa_fat.majs_user_id', '=', $this->user->id());
410 409
             })
411
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
410
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
412 411
                 // Link to sosa's mother
413
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
412
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
414 413
                 ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
415 414
                 ->where('sosa_mot.majs_user_id', '=', $this->user->id());
416 415
             })
417 416
             ->where('sosa.majs_gedcom_id', '=', $this->tree->id())
418 417
             ->where('sosa.majs_user_id', '=', $this->user->id())
419 418
             ->where('sosa.majs_gen', '>=', $gen)
420
-            ->where(function (Builder $query): void {
419
+            ->where(function(Builder $query): void {
421 420
                 $query->whereNull('sosa_fat.majs_i_id')
422 421
                     ->orWhereNull('sosa_mot.majs_i_id');
423 422
             })
@@ -426,11 +425,11 @@  discard block
 block discarded – undo
426 425
         return DB::table('maj_sosa AS sosa_list')
427 426
             ->select(['stats_by_gen.root_ancestor AS root_ancestor_sosa', 'sosa_list.majs_i_id as root_ancestor_id'])
428 427
             ->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
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
428
+            ->selectRaw(' SQRT('.
429
+                '   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
430
+                '   - 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
432 431
                 ' ) AS stddev_gen_depth')
433
-            ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function (JoinClause $join): void {
432
+            ->joinSub($missing_ancestors_by_gen, 'stats_by_gen', function(JoinClause $join): void {
434 433
                 $join->on('sosa_list.majs_sosa', '=', 'stats_by_gen.root_ancestor')
435 434
                     ->where('sosa_list.majs_gedcom_id', '=', $this->tree->id())
436 435
                     ->where('sosa_list.majs_user_id', '=', $this->user->id());
@@ -459,16 +458,16 @@  discard block
 block discarded – undo
459 458
         $table_prefix = DB::connection()->getTablePrefix();
460 459
         $multiple_ancestors = DB::table('maj_sosa AS sosa')
461 460
             ->select('sosa.majs_i_id AS sosa_i_id')
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 {
461
+            ->selectRaw('COUNT('.$table_prefix.'sosa.majs_sosa) AS sosa_count')
462
+            ->leftJoin('maj_sosa AS sosa_fat', function(JoinClause $join) use ($table_prefix): void {
464 463
                 // Link to sosa's father
465
-                $join->whereRaw($table_prefix . 'sosa_fat.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa')
464
+                $join->whereRaw($table_prefix.'sosa_fat.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa')
466 465
                     ->where('sosa_fat.majs_gedcom_id', '=', $this->tree->id())
467 466
                     ->where('sosa_fat.majs_user_id', '=', $this->user->id());
468 467
             })
469
-            ->leftJoin('maj_sosa AS sosa_mot', function (JoinClause $join) use ($table_prefix): void {
468
+            ->leftJoin('maj_sosa AS sosa_mot', function(JoinClause $join) use ($table_prefix): void {
470 469
                 // Link to sosa's mother
471
-                $join->whereRaw($table_prefix . 'sosa_mot.majs_sosa = 2 * ' . $table_prefix . 'sosa.majs_sosa + 1')
470
+                $join->whereRaw($table_prefix.'sosa_mot.majs_sosa = 2 * '.$table_prefix.'sosa.majs_sosa + 1')
472 471
                 ->where('sosa_mot.majs_gedcom_id', '=', $this->tree->id())
473 472
                 ->where('sosa_mot.majs_user_id', '=', $this->user->id());
474 473
             })
@@ -477,15 +476,15 @@  discard block
 block discarded – undo
477 476
             ->whereNull('sosa_fat.majs_sosa')   // We keep only root individuals, i.e. those with no father or mother
478 477
             ->whereNull('sosa_mot.majs_sosa')
479 478
             ->groupBy('sosa.majs_i_id')
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
479
+            ->havingRaw('COUNT('.$table_prefix.'sosa.majs_sosa) > 1')    // Limit to the duplicate sosas.
480
+            ->orderByRaw('COUNT('.$table_prefix.'sosa.majs_sosa) DESC, MIN('.$table_prefix.'sosa.majs_sosa) ASC')   //@phpcs:ignore Generic.Files.LineLength.TooLong
482 481
             ->limit($limit + 1)     // We want to select one more than required, for ties
483 482
             ->get();
484 483
 
485 484
         if ($multiple_ancestors->count() > $limit) {
486 485
             $last_count = $multiple_ancestors->last()->sosa_count;
487
-            $multiple_ancestors = $multiple_ancestors->reject(function ($element) use ($last_count): bool {
488
-                return $element->sosa_count ==  $last_count;
486
+            $multiple_ancestors = $multiple_ancestors->reject(function($element) use ($last_count): bool {
487
+                return $element->sosa_count == $last_count;
489 488
             });
490 489
         }
491 490
         return $multiple_ancestors;
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Services/SosaCalculatorService.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@
 block discarded – undo
74 74
         $this->tmp_sosa_table = array();
75 75
         $max_gen_setting = $tree->getUserPreference($user, 'MAJ_SOSA_MAX_GEN');
76 76
         $this->max_generations = is_numeric($max_gen_setting) ?
77
-            (int) $max_gen_setting :
78
-            $this->sosa_records_service->maxSystemGenerations();
77
+            (int)$max_gen_setting : $this->sosa_records_service->maxSystemGenerations();
79 78
     }
80 79
 
81 80
     /**
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaStatistics.php 1 patch
Spacing   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         /** @var SosaStatisticsService $sosa_stats_service */
72 72
         $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
73 73
 
74
-        return $this->viewResponse($this->module->name() . '::statistics-page', [
74
+        return $this->viewResponse($this->module->name().'::statistics-page', [
75 75
             'module_name'       =>  $this->module->name(),
76 76
             'title'             =>  I18N::translate('Sosa Statistics'),
77 77
             'tree'              =>  $tree,
@@ -126,37 +126,34 @@  discard block
 block discarded – undo
126 126
 
127 127
         foreach ($stats_by_gen as $gen => $stats_gen) {
128 128
             $gen_diff = $gen > 1 ?
129
-                (int) $stats_gen['diffSosaTotalCount'] - (int) $stats_by_gen[$gen - 1]['diffSosaTotalCount'] :
130
-                1;
129
+                (int)$stats_gen['diffSosaTotalCount'] - (int)$stats_by_gen[$gen - 1]['diffSosaTotalCount'] : 1;
131 130
             $generation_stats[$gen] = array(
132
-                'gen_min_birth' => $stats_gen['firstBirth'] ?? (int) $stats_gen['firstEstimatedBirth'],
133
-                'gen_max_birth' => $stats_gen['lastBirth'] ?? (int) $stats_gen['lastEstimatedBirth'],
131
+                'gen_min_birth' => $stats_gen['firstBirth'] ?? (int)$stats_gen['firstEstimatedBirth'],
132
+                'gen_max_birth' => $stats_gen['lastBirth'] ?? (int)$stats_gen['lastEstimatedBirth'],
134 133
                 'theoretical' => BigInteger::of(2)->power($gen - 1)->toInt(),
135
-                'known' => (int) $stats_gen['sosaCount'],
134
+                'known' => (int)$stats_gen['sosaCount'],
136 135
                 'perc_known' => $this->safeDivision(
137
-                    BigInteger::of((int) $stats_gen['sosaCount']),
136
+                    BigInteger::of((int)$stats_gen['sosaCount']),
138 137
                     BigInteger::of(2)->power($gen - 1)
139 138
                 ),
140 139
                 'missing' => $gen > 1 ?
141
-                    2 * (int) $stats_by_gen[$gen - 1]['sosaCount'] - (int) $stats_gen['sosaCount'] :
142
-                    0,
140
+                    2 * (int)$stats_by_gen[$gen - 1]['sosaCount'] - (int)$stats_gen['sosaCount'] : 0,
143 141
                 'perc_missing' => $gen > 1 ?
144 142
                     1 - $this->safeDivision(
145
-                        BigInteger::of((int) $stats_gen['sosaCount']),
146
-                        BigInteger::of(2 * (int) $stats_by_gen[$gen - 1]['sosaCount'])
147
-                    ) :
148
-                    0,
149
-                'total_known' => (int) $stats_gen['sosaTotalCount'],
143
+                        BigInteger::of((int)$stats_gen['sosaCount']),
144
+                        BigInteger::of(2 * (int)$stats_by_gen[$gen - 1]['sosaCount'])
145
+                    ) : 0,
146
+                'total_known' => (int)$stats_gen['sosaTotalCount'],
150 147
                 'perc_total_known' => $this->safeDivision(
151
-                    BigInteger::of((int) $stats_gen['sosaTotalCount']),
148
+                    BigInteger::of((int)$stats_gen['sosaTotalCount']),
152 149
                     BigInteger::of(2)->power($gen)->minus(1)
153 150
                 ),
154 151
                 'different' => $gen_diff,
155 152
                 'perc_different' => $this->safeDivision(
156 153
                     BigInteger::of($gen_diff),
157
-                    BigInteger::of((int) $stats_gen['sosaCount'])
154
+                    BigInteger::of((int)$stats_gen['sosaCount'])
158 155
                 ),
159
-                'total_different' => (int) $stats_gen['diffSosaTotalCount']
156
+                'total_different' => (int)$stats_gen['diffSosaTotalCount']
160 157
             );
161 158
         }
162 159
 
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/PedigreeCollapseData.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@
 block discarded – undo
67 67
         $sosa_stats_service = app()->makeWith(SosaStatisticsService::class, ['tree' => $tree, 'user' => $user]);
68 68
         $pedi_collapse_data = $sosa_stats_service->pedigreeCollapseByGenerationData();
69 69
 
70
-        $response = [ 'cells' => [] ];
70
+        $response = ['cells' => []];
71 71
         $last_pedi_collapse = 0;
72 72
         foreach ($pedi_collapse_data as $gen => $rec) {
73
-            $response['cells'][$gen] = view($this->module->name() . '::components/pedigree-collapse-cell', [
73
+            $response['cells'][$gen] = view($this->module->name().'::components/pedigree-collapse-cell', [
74 74
                 'pedi_collapse_roots'   =>  $rec['pedi_collapse_roots'],
75 75
                 'pedi_collapse_xgen'    =>  $rec['pedi_collapse_xgen']
76 76
             ]);
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaConfigAction.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
         $params = $request->getParsedBody();
58 58
         assert(is_array($params));
59 59
 
60
-        $user_id = (int) $params['sosa-userid'];
60
+        $user_id = (int)$params['sosa-userid'];
61 61
         $root_id = $params['sosa-rootid'] ?? '';
62 62
         $max_gen = $params['sosa-maxgen'] ?? '';
63 63
 
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/Http/RequestHandlers/SosaConfig.php 1 patch
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,16 +86,15 @@
 block discarded – undo
86 86
         $max_gen_system = app(SosaRecordsService::class)->maxSystemGenerations();
87 87
         foreach ($users_root as $key => $user_root) {
88 88
             $users_root[$key]['max_gen'] = is_numeric($user_root['max_gen']) ?
89
-                (int) $user_root['max_gen'] :
90
-                $max_gen_system;
89
+                (int)$user_root['max_gen'] : $max_gen_system;
91 90
         };
92 91
 
93
-        return $this->viewResponse($this->module->name() . '::config-page', [
92
+        return $this->viewResponse($this->module->name().'::config-page', [
94 93
             'module_name'       =>  $this->module->name(),
95 94
             'title'             =>  I18N::translate('Sosa Configuration'),
96 95
             'tree'              =>  $tree,
97 96
             'user_id'           =>  $request->getAttribute('user'),
98
-            'selected_user_id'  =>  (int) ($request->getQueryParams()['user_id'] ?? 0),
97
+            'selected_user_id'  =>  (int)($request->getQueryParams()['user_id'] ?? 0),
99 98
             'immediate_compute' =>  ($request->getQueryParams()['compute'] ?? '') == 'yes',
100 99
             'users_root'        =>  $users_root
101 100
         ]);
Please login to merge, or discard this patch.
src/Webtrees/Module/Sosa/SosaModule.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 
59 59
     private const SCHEMA_TARGET_VERSION   = 3;
60 60
     private const SCHEMA_SETTING_NAME     = 'MAJ_SOSA_SCHEMA_VERSION';
61
-    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema';
61
+    private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__.'\Schema';
62 62
 /**
63 63
      * {@inheritDoc}
64 64
      * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function loadRoutes(Map $router): void
100 100
     {
101
-        $router->attach('', '', static function (Map $router): void {
101
+        $router->attach('', '', static function(Map $router): void {
102 102
 
103
-            $router->attach('', '/module-maj/sosa', static function (Map $router): void {
103
+            $router->attach('', '/module-maj/sosa', static function(Map $router): void {
104 104
 
105
-                $router->attach('', '/list', static function (Map $router): void {
105
+                $router->attach('', '/list', static function(Map $router): void {
106 106
 
107 107
                     $router->get(AncestorsList::class, '/ancestors/{tree}{/gen}', AncestorsList::class);
108
-                    $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class);    //phpcs:ignore Generic.Files.LineLength.TooLong
109
-                    $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class);   //phpcs:ignore Generic.Files.LineLength.TooLong
108
+                    $router->get(AncestorsListIndividual::class, '/ancestors/{tree}/{gen}/tab/individuals', AncestorsListIndividual::class); //phpcs:ignore Generic.Files.LineLength.TooLong
109
+                    $router->get(AncestorsListFamily::class, '/ancestors/{tree}/{gen}/tab/families', AncestorsListFamily::class); //phpcs:ignore Generic.Files.LineLength.TooLong
110 110
                     $router->get(MissingAncestorsList::class, '/missing/{tree}{/gen}', MissingAncestorsList::class);
111 111
                 });
112 112
 
113
-                $router->attach('', '/statistics/{tree}', static function (Map $router): void {
113
+                $router->attach('', '/statistics/{tree}', static function(Map $router): void {
114 114
 
115 115
                     $router->get(SosaStatistics::class, '', SosaStatistics::class);
116 116
                     $router->get(PedigreeCollapseData::class, '/pedigreecollapse', PedigreeCollapseData::class);
117 117
                 });
118 118
 
119
-                $router->attach('', '/config/{tree}', static function (Map $router): void {
119
+                $router->attach('', '/config/{tree}', static function(Map $router): void {
120 120
 
121 121
                     $router->get(SosaConfig::class, '', SosaConfig::class);
122 122
                     $router->post(SosaConfigAction::class, '', SosaConfigAction::class);
@@ -215,6 +215,6 @@  discard block
 block discarded – undo
215 215
      */
216 216
     public function headContent(): string
217 217
     {
218
-        return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">';
218
+        return '<link rel="stylesheet" href="'.e($this->moduleCssUrl()).'">';
219 219
     }
220 220
 }
Please login to merge, or discard this patch.