Completed
Pull Request — master (#1866)
by Rico
52:31 queued 43:48
created
app/Stats.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     private function getTags($text): array
157 157
     {
158 158
         // Extract all tags from the provided text
159
-        preg_match_all('/#([^#]+)(?=#)/', (string)$text, $match);
159
+        preg_match_all('/#([^#]+)(?=#)/', (string) $text, $match);
160 160
         $tags       = $match[1];
161 161
         $c          = count($tags);
162 162
         $new_tags   = []; // tag to replace
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      */
393 393
     private function totalIndividualsQuery(): int
394 394
     {
395
-        return (int)Database::prepare(
395
+        return (int) Database::prepare(
396 396
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id"
397 397
         )->execute([
398 398
             'tree_id' => $this->tree->getTreeId(),
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
      */
417 417
     private function totalIndisWithSourcesQuery(): int
418 418
     {
419
-        return (int)Database::prepare(
419
+        return (int) Database::prepare(
420 420
             "SELECT COUNT(DISTINCT i_id)" .
421 421
             " FROM `##individuals` JOIN `##link` ON i_id = l_from AND i_file = l_file" .
422 422
             " WHERE l_file = :tree_id AND l_type = 'SOUR'"
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
      */
500 500
     private function totalFamiliesQuery(): int
501 501
     {
502
-        return (int)Database::prepare(
502
+        return (int) Database::prepare(
503 503
             "SELECT COUNT(*) FROM `##families` WHERE f_file = :tree_id"
504 504
         )->execute([
505 505
             'tree_id' => $this->tree->getTreeId(),
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
      */
524 524
     private function totalFamsWithSourcesQuery(): int
525 525
     {
526
-        return (int)Database::prepare(
526
+        return (int) Database::prepare(
527 527
             "SELECT COUNT(DISTINCT f_id)" .
528 528
             " FROM `##families` JOIN `##link` ON f_id = l_from AND f_file = l_file" .
529 529
             " WHERE l_file = :tree_id AND l_type = 'SOUR'"
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      */
607 607
     private function totalSourcesQuery(): int
608 608
     {
609
-        return (int)Database::prepare(
609
+        return (int) Database::prepare(
610 610
             "SELECT COUNT(*) FROM `##sources` WHERE s_file = :tree_id"
611 611
         )->execute([
612 612
             'tree_id' => $this->tree->getTreeId(),
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      */
641 641
     private function totalNotesQuery(): int
642 642
     {
643
-        return (int)Database::prepare(
643
+        return (int) Database::prepare(
644 644
             "SELECT COUNT(*) FROM `##other` WHERE o_type='NOTE' AND o_file = :tree_id"
645 645
         )->execute([
646 646
             'tree_id' => $this->tree->getTreeId(),
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
      */
675 675
     private function totalRepositoriesQuery(): int
676 676
     {
677
-        return (int)Database::prepare(
677
+        return (int) Database::prepare(
678 678
             "SELECT COUNT(*) FROM `##other` WHERE o_type='REPO' AND o_file = :tree_id"
679 679
         )->execute([
680 680
             'tree_id' => $this->tree->getTreeId(),
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
                 }
786 786
             }
787 787
             if ($types) {
788
-                $sql  .= ' AND d_fact IN (' . implode(', ', array_fill(0, count($types), '?')) . ')';
788
+                $sql .= ' AND d_fact IN (' . implode(', ', array_fill(0, count($types), '?')) . ')';
789 789
                 $vars = array_merge($vars, $types);
790 790
             }
791 791
         }
792
-        $sql  .= ' AND d_fact NOT IN (' . implode(', ', array_fill(0, count($no_types), '?')) . ')';
792
+        $sql .= ' AND d_fact NOT IN (' . implode(', ', array_fill(0, count($no_types), '?')) . ')';
793 793
         $vars = array_merge($vars, $no_types);
794 794
 
795 795
         $n = (int) Database::prepare($sql)->execute($vars)->fetchOne();
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
      */
902 902
     private function totalSexMalesQuery(): int
903 903
     {
904
-        return (int)Database::prepare(
904
+        return (int) Database::prepare(
905 905
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_sex = 'M'"
906 906
         )->execute([
907 907
             'tree_id' => $this->tree->getTreeId(),
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
      */
936 936
     private function totalSexFemalesQuery(): int
937 937
     {
938
-        return (int)Database::prepare(
938
+        return (int) Database::prepare(
939 939
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_sex = 'F'"
940 940
         )->execute([
941 941
             'tree_id' => $this->tree->getTreeId(),
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
      */
970 970
     private function totalSexUnknownQuery(): int
971 971
     {
972
-        return (int)Database::prepare(
972
+        return (int) Database::prepare(
973 973
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_sex = 'U'"
974 974
         )->execute([
975 975
             'tree_id' => $this->tree->getTreeId(),
@@ -1043,12 +1043,12 @@  discard block
 block discarded – undo
1043 1043
         }
1044 1044
 
1045 1045
         if ($tot_u > 0) {
1046
-            $chd         = $this->arrayToExtendedEncoding([
1046
+            $chd = $this->arrayToExtendedEncoding([
1047 1047
                 4095 * $tot_u / $tot,
1048 1048
                 4095 * $tot_f / $tot,
1049 1049
                 4095 * $tot_m / $tot,
1050 1050
             ]);
1051
-            $chl         =
1051
+            $chl =
1052 1052
                 I18N::translateContext('unknown people', 'Unknown') . ' - ' . $per_u . '|' .
1053 1053
                 I18N::translate('Females') . ' - ' . $per_f . '|' .
1054 1054
                 I18N::translate('Males') . ' - ' . $per_m;
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
             return "<img src=\"https://chart.googleapis.com/chart?cht=p3&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_unknown},{$color_female},{$color_male}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . '" title="' . $chart_title . '" />';
1061 1061
         }
1062 1062
 
1063
-        $chd         = $this->arrayToExtendedEncoding([
1063
+        $chd = $this->arrayToExtendedEncoding([
1064 1064
             4095 * $tot_f / $tot,
1065 1065
             4095 * $tot_m / $tot,
1066 1066
         ]);
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
      */
1086 1086
     private function totalLivingQuery(): int
1087 1087
     {
1088
-        return (int)Database::prepare(
1088
+        return (int) Database::prepare(
1089 1089
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
1090 1090
         )->execute([
1091 1091
             'tree_id' => $this->tree->getTreeId(),
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
      */
1120 1120
     private function totalDeceasedQuery(): int
1121 1121
     {
1122
-        return (int)Database::prepare(
1122
+        return (int) Database::prepare(
1123 1123
             "SELECT COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
1124 1124
         )->execute([
1125 1125
             'tree_id' => $this->tree->getTreeId(),
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
             return '';
1186 1186
         }
1187 1187
 
1188
-        $chd         = $this->arrayToExtendedEncoding([
1188
+        $chd = $this->arrayToExtendedEncoding([
1189 1189
             4095 * $tot_l / $tot,
1190 1190
             4095 * $tot_d / $tot,
1191 1191
         ]);
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
     public function totalUsers($params = []): string
1209 1209
     {
1210 1210
         if (isset($params[0])) {
1211
-            $total = count(User::all()) + (int)$params[0];
1211
+            $total = count(User::all()) + (int) $params[0];
1212 1212
         } else {
1213 1213
             $total = count(User::all());
1214 1214
         }
@@ -1255,18 +1255,18 @@  discard block
 block discarded – undo
1255 1255
             if ($type == 'unknown') {
1256 1256
                 // There has to be a better way then this :(
1257 1257
                 foreach ($this->media_types as $t) {
1258
-                    $sql    .= " AND (m_gedcom NOT LIKE ? AND m_gedcom NOT LIKE ?)";
1258
+                    $sql .= " AND (m_gedcom NOT LIKE ? AND m_gedcom NOT LIKE ?)";
1259 1259
                     $vars[] = "%3 TYPE {$t}%";
1260 1260
                     $vars[] = "%1 _TYPE {$t}%";
1261 1261
                 }
1262 1262
             } else {
1263
-                $sql    .= " AND (m_gedcom LIKE ? OR m_gedcom LIKE ?)";
1263
+                $sql .= " AND (m_gedcom LIKE ? OR m_gedcom LIKE ?)";
1264 1264
                 $vars[] = "%3 TYPE {$type}%";
1265 1265
                 $vars[] = "%1 _TYPE {$type}%";
1266 1266
             }
1267 1267
         }
1268 1268
 
1269
-        return (int)Database::prepare($sql)->execute($vars)->fetchOne();
1269
+        return (int) Database::prepare($sql)->execute($vars)->fetchOne();
1270 1270
     }
1271 1271
 
1272 1272
     /**
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
     private function totalPlacesQuery(): int
1730 1730
     {
1731 1731
         return
1732
-            (int)Database::prepare("SELECT COUNT(*) FROM `##places` WHERE p_file=?")
1732
+            (int) Database::prepare("SELECT COUNT(*) FROM `##places` WHERE p_file=?")
1733 1733
                 ->execute([$this->tree->getTreeId()])
1734 1734
                 ->fetchOne();
1735 1735
     }
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
         $chart_url .= '&amp;chs=' . $WT_STATS_MAP_X . 'x' . $WT_STATS_MAP_Y;
1900 1900
         $chart_url .= '&amp;chld=' . implode('', array_keys($surn_countries)) . '&amp;chd=s:';
1901 1901
         foreach ($surn_countries as $count) {
1902
-            $chart_url .= substr(self::GOOGLE_CHART_ENCODING, (int)($count / max($surn_countries) * 61), 1);
1902
+            $chart_url .= substr(self::GOOGLE_CHART_ENCODING, (int) ($count / max($surn_countries) * 61), 1);
1903 1903
         }
1904 1904
         $chart = '<div id="google_charts" class="center">';
1905 1905
         $chart .= '<p>' . $chart_title . '</p>';
@@ -1941,9 +1941,9 @@  discard block
 block discarded – undo
1941 1941
             $country = trim($place->country);
1942 1942
             if (array_key_exists($country, $country_names)) {
1943 1943
                 if (!isset($all_db_countries[$country_names[$country]][$country])) {
1944
-                    $all_db_countries[$country_names[$country]][$country] = (int)$place->tot;
1944
+                    $all_db_countries[$country_names[$country]][$country] = (int) $place->tot;
1945 1945
                 } else {
1946
-                    $all_db_countries[$country_names[$country]][$country] += (int)$place->tot;
1946
+                    $all_db_countries[$country_names[$country]][$country] += (int) $place->tot;
1947 1947
                 }
1948 1948
             }
1949 1949
         }
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
             $centuries = '';
2121 2121
             $counts    = [];
2122 2122
             foreach ($rows as $values) {
2123
-                $counts[]  = round(100 * $values->total / $tot, 0);
2123
+                $counts[] = round(100 * $values->total / $tot, 0);
2124 2124
                 $centuries .= $this->centuryName($values->century) . ' - ' . I18N::number($values->total) . '|';
2125 2125
             }
2126 2126
             $chd = $this->arrayToExtendedEncoding($counts);
@@ -2214,7 +2214,7 @@  discard block
 block discarded – undo
2214 2214
             $centuries = '';
2215 2215
             $counts    = [];
2216 2216
             foreach ($rows as $values) {
2217
-                $counts[]  = round(100 * $values->total / $tot, 0);
2217
+                $counts[] = round(100 * $values->total / $tot, 0);
2218 2218
                 $centuries .= $this->centuryName($values->century) . ' - ' . I18N::number($values->total) . '|';
2219 2219
             }
2220 2220
             $chd = $this->arrayToExtendedEncoding($counts);
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
                 }
2465 2465
                 break;
2466 2466
             case 'age':
2467
-                $result = I18N::number((int)($row->age / 365.25));
2467
+                $result = I18N::number((int) ($row->age / 365.25));
2468 2468
                 break;
2469 2469
             case 'name':
2470 2470
                 $result = '<a href="' . e($person->url()) . '">' . $person->getFullName() . '</a>';
@@ -2493,7 +2493,7 @@  discard block
 block discarded – undo
2493 2493
             $sex_search = '';
2494 2494
         }
2495 2495
         if (isset($params[0])) {
2496
-            $total = (int)$params[0];
2496
+            $total = (int) $params[0];
2497 2497
         } else {
2498 2498
             $total = 10;
2499 2499
         }
@@ -2527,10 +2527,10 @@  discard block
 block discarded – undo
2527 2527
         foreach ($rows as $row) {
2528 2528
             $person = Individual::getInstance($row->deathdate, $this->tree);
2529 2529
             $age    = $row->age;
2530
-            if ((int)($age / 365.25) > 0) {
2531
-                $age = (int)($age / 365.25) . 'y';
2532
-            } elseif ((int)($age / 30.4375) > 0) {
2533
-                $age = (int)($age / 30.4375) . 'm';
2530
+            if ((int) ($age / 365.25) > 0) {
2531
+                $age = (int) ($age / 365.25) . 'y';
2532
+            } elseif ((int) ($age / 30.4375) > 0) {
2533
+                $age = (int) ($age / 30.4375) . 'm';
2534 2534
             } else {
2535 2535
                 $age = $age . 'd';
2536 2536
             }
@@ -2592,11 +2592,11 @@  discard block
 block discarded – undo
2592 2592
             $sex_search = '';
2593 2593
         }
2594 2594
         if (isset($params[0])) {
2595
-            $total = (int)$params[0];
2595
+            $total = (int) $params[0];
2596 2596
         } else {
2597 2597
             $total = 10;
2598 2598
         }
2599
-        $rows  = $this->runSql(
2599
+        $rows = $this->runSql(
2600 2600
             "SELECT" .
2601 2601
             " birth.d_gid AS id," .
2602 2602
             " MIN(birth.d_julianday1) AS age" .
@@ -2619,10 +2619,10 @@  discard block
 block discarded – undo
2619 2619
         foreach ($rows as $row) {
2620 2620
             $person = Individual::getInstance($row->id, $this->tree);
2621 2621
             $age    = (WT_CLIENT_JD - $row->age);
2622
-            if ((int)($age / 365.25) > 0) {
2623
-                $age = (int)($age / 365.25) . 'y';
2624
-            } elseif ((int)($age / 30.4375) > 0) {
2625
-                $age = (int)($age / 30.4375) . 'm';
2622
+            if ((int) ($age / 365.25) > 0) {
2623
+                $age = (int) ($age / 365.25) . 'y';
2624
+            } elseif ((int) ($age / 30.4375) > 0) {
2625
+                $age = (int) ($age / 30.4375) . 'm';
2626 2626
             } else {
2627 2627
                 $age = $age . 'd';
2628 2628
             }
@@ -2699,10 +2699,10 @@  discard block
 block discarded – undo
2699 2699
 
2700 2700
         $age = $rows[0]->age;
2701 2701
         if ($show_years) {
2702
-            if ((int)($age / 365.25) > 0) {
2703
-                $age = (int)($age / 365.25) . 'y';
2704
-            } elseif ((int)($age / 30.4375) > 0) {
2705
-                $age = (int)($age / 30.4375) . 'm';
2702
+            if ((int) ($age / 365.25) > 0) {
2703
+                $age = (int) ($age / 365.25) . 'y';
2704
+            } elseif ((int) ($age / 30.4375) > 0) {
2705
+                $age = (int) ($age / 30.4375) . 'm';
2706 2706
             } elseif (!empty($age)) {
2707 2707
                 $age = $age . 'd';
2708 2708
             }
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
                 if ($sizes[0] < 980) {
2773 2773
                     $sizes[0] += 50;
2774 2774
                 }
2775
-                $chxl    .= $this->centuryName($century) . '|';
2775
+                $chxl .= $this->centuryName($century) . '|';
2776 2776
                 $average = 0;
2777 2777
                 if (isset($values['F'])) {
2778 2778
                     $countsf .= $values['F'] . ',';
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
                 while ($offset = strpos($title, ' ', $offset + 1)) {
2815 2815
                     $counter[] = $offset;
2816 2816
                 }
2817
-                $half = (int)(count($counter) / 2);
2817
+                $half = (int) (count($counter) / 2);
2818 2818
                 $chtt = substr_replace($title, '|', $counter[$half], 1);
2819 2819
             }
2820 2820
 
@@ -3390,16 +3390,16 @@  discard block
 block discarded – undo
3390 3390
             case 'age':
3391 3391
                 $age = $row->age;
3392 3392
                 if ($show_years) {
3393
-                    if ((int)($age / 365.25) > 0) {
3394
-                        $age = (int)($age / 365.25) . 'y';
3395
-                    } elseif ((int)($age / 30.4375) > 0) {
3396
-                        $age = (int)($age / 30.4375) . 'm';
3393
+                    if ((int) ($age / 365.25) > 0) {
3394
+                        $age = (int) ($age / 365.25) . 'y';
3395
+                    } elseif ((int) ($age / 30.4375) > 0) {
3396
+                        $age = (int) ($age / 30.4375) . 'm';
3397 3397
                     } else {
3398 3398
                         $age = $age . 'd';
3399 3399
                     }
3400 3400
                     $result = FunctionsDate::getAgeAtEvent($age);
3401 3401
                 } else {
3402
-                    $result = I18N::number((int)($age / 365.25));
3402
+                    $result = I18N::number((int) ($age / 365.25));
3403 3403
                 }
3404 3404
                 break;
3405 3405
         }
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
     private function ageOfMarriageQuery($type = 'list', $age_dir = 'ASC', $params = []): string
3420 3420
     {
3421 3421
         if (isset($params[0])) {
3422
-            $total = (int)$params[0];
3422
+            $total = (int) $params[0];
3423 3423
         } else {
3424 3424
             $total = 10;
3425 3425
         }
@@ -3502,10 +3502,10 @@  discard block
 block discarded – undo
3502 3502
             if ($type === 'name') {
3503 3503
                 return $family->formatList();
3504 3504
             }
3505
-            if ((int)($age / 365.25) > 0) {
3506
-                $age = (int)($age / 365.25) . 'y';
3507
-            } elseif ((int)($age / 30.4375) > 0) {
3508
-                $age = (int)($age / 30.4375) . 'm';
3505
+            if ((int) ($age / 365.25) > 0) {
3506
+                $age = (int) ($age / 365.25) . 'y';
3507
+            } elseif ((int) ($age / 30.4375) > 0) {
3508
+                $age = (int) ($age / 30.4375) . 'm';
3509 3509
             } else {
3510 3510
                 $age = $age . 'd';
3511 3511
             }
@@ -3567,7 +3567,7 @@  discard block
 block discarded – undo
3567 3567
     private function ageBetweenSpousesQuery($type = 'list', $age_dir = 'DESC', $params = []): string
3568 3568
     {
3569 3569
         if (isset($params[0])) {
3570
-            $total = (int)$params[0];
3570
+            $total = (int) $params[0];
3571 3571
         } else {
3572 3572
             $total = 10;
3573 3573
         }
@@ -3612,10 +3612,10 @@  discard block
 block discarded – undo
3612 3612
                 break;
3613 3613
             }
3614 3614
             $age = $fam->age;
3615
-            if ((int)($age / 365.25) > 0) {
3616
-                $age = (int)($age / 365.25) . 'y';
3617
-            } elseif ((int)($age / 30.4375) > 0) {
3618
-                $age = (int)($age / 30.4375) . 'm';
3615
+            if ((int) ($age / 365.25) > 0) {
3616
+                $age = (int) ($age / 365.25) . 'y';
3617
+            } elseif ((int) ($age / 30.4375) > 0) {
3618
+                $age = (int) ($age / 30.4375) . 'm';
3619 3619
             } else {
3620 3620
                 $age = $age . 'd';
3621 3621
             }
@@ -3703,16 +3703,16 @@  discard block
 block discarded – undo
3703 3703
             case 'age':
3704 3704
                 $age = $row->age;
3705 3705
                 if ($show_years) {
3706
-                    if ((int)($age / 365.25) > 0) {
3707
-                        $age = (int)($age / 365.25) . 'y';
3708
-                    } elseif ((int)($age / 30.4375) > 0) {
3709
-                        $age = (int)($age / 30.4375) . 'm';
3706
+                    if ((int) ($age / 365.25) > 0) {
3707
+                        $age = (int) ($age / 365.25) . 'y';
3708
+                    } elseif ((int) ($age / 30.4375) > 0) {
3709
+                        $age = (int) ($age / 30.4375) . 'm';
3710 3710
                     } else {
3711 3711
                         $age = $age . 'd';
3712 3712
                     }
3713 3713
                     $result = FunctionsDate::getAgeAtEvent($age);
3714 3714
                 } else {
3715
-                    $result = (int)($age / 365.25);
3715
+                    $result = (int) ($age / 365.25);
3716 3716
                 }
3717 3717
                 break;
3718 3718
         }
@@ -3796,7 +3796,7 @@  discard block
 block discarded – undo
3796 3796
             $sizes = explode('x', $size);
3797 3797
             $tot   = 0;
3798 3798
             foreach ($rows as $values) {
3799
-                $tot += (int)$values->total;
3799
+                $tot += (int) $values->total;
3800 3800
             }
3801 3801
             // Beware divide by zero
3802 3802
             if ($tot === 0) {
@@ -3805,7 +3805,7 @@  discard block
 block discarded – undo
3805 3805
             $centuries = '';
3806 3806
             $counts    = [];
3807 3807
             foreach ($rows as $values) {
3808
-                $counts[]  = round(100 * $values->total / $tot, 0);
3808
+                $counts[] = round(100 * $values->total / $tot, 0);
3809 3809
                 $centuries .= $this->centuryName($values->century) . ' - ' . I18N::number($values->total) . '|';
3810 3810
             }
3811 3811
             $chd = $this->arrayToExtendedEncoding($counts);
@@ -3901,7 +3901,7 @@  discard block
 block discarded – undo
3901 3901
             $centuries = '';
3902 3902
             $counts    = [];
3903 3903
             foreach ($rows as $values) {
3904
-                $counts[]  = round(100 * $values->total / $tot, 0);
3904
+                $counts[] = round(100 * $values->total / $tot, 0);
3905 3905
                 $centuries .= $this->centuryName($values->century) . ' - ' . I18N::number($values->total) . '|';
3906 3906
             }
3907 3907
             $chd = $this->arrayToExtendedEncoding($counts);
@@ -4170,7 +4170,7 @@  discard block
 block discarded – undo
4170 4170
                 if ($sizes[0] < 1000) {
4171 4171
                     $sizes[0] += 50;
4172 4172
                 }
4173
-                $chxl    .= $this->centuryName($century) . '|';
4173
+                $chxl .= $this->centuryName($century) . '|';
4174 4174
                 $average = 0;
4175 4175
                 if (isset($values['F'])) {
4176 4176
                     if ($max <= 50) {
@@ -4227,7 +4227,7 @@  discard block
 block discarded – undo
4227 4227
                 while ($offset = strpos(I18N::translate('Average age in century of marriage'), ' ', $offset + 1)) {
4228 4228
                     $counter[] = $offset;
4229 4229
                 }
4230
-                $half = (int)(count($counter) / 2);
4230
+                $half = (int) (count($counter) / 2);
4231 4231
                 $chtt = substr_replace(I18N::translate('Average age in century of marriage'), '|', $counter[$half], 1);
4232 4232
             }
4233 4233
 
@@ -4763,7 +4763,7 @@  discard block
 block discarded – undo
4763 4763
     private function topTenFamilyQuery($type = 'list', $params = []): string
4764 4764
     {
4765 4765
         if (isset($params[0])) {
4766
-            $total = (int)$params[0];
4766
+            $total = (int) $params[0];
4767 4767
         } else {
4768 4768
             $total = 10;
4769 4769
         }
@@ -4830,7 +4830,7 @@  discard block
 block discarded – undo
4830 4830
     private function ageBetweenSiblingsQuery($type = 'list', $params = []): string
4831 4831
     {
4832 4832
         if (isset($params[0])) {
4833
-            $total = (int)$params[0];
4833
+            $total = (int) $params[0];
4834 4834
         } else {
4835 4835
             $total = 10;
4836 4836
         }
@@ -4886,10 +4886,10 @@  discard block
 block discarded – undo
4886 4886
                 return $return;
4887 4887
             }
4888 4888
             $age = $fam->age;
4889
-            if ((int)($age / 365.25) > 0) {
4890
-                $age = (int)($age / 365.25) . 'y';
4891
-            } elseif ((int)($age / 30.4375) > 0) {
4892
-                $age = (int)($age / 30.4375) . 'm';
4889
+            if ((int) ($age / 365.25) > 0) {
4890
+                $age = (int) ($age / 365.25) . 'y';
4891
+            } elseif ((int) ($age / 30.4375) > 0) {
4892
+                $age = (int) ($age / 30.4375) . 'm';
4893 4893
             } else {
4894 4894
                 $age = $age . 'd';
4895 4895
             }
@@ -4900,7 +4900,7 @@  discard block
 block discarded – undo
4900 4900
             if ($type == 'list') {
4901 4901
                 if ($one && !in_array($fam->family, $dist)) {
4902 4902
                     if ($child1->canShow() && $child2->canShow()) {
4903
-                        $return  = '<li>';
4903
+                        $return = '<li>';
4904 4904
                         $return  .= '<a href="' . e($child2->url()) . '">' . $child2->getFullName() . '</a> ';
4905 4905
                         $return  .= I18N::translate('and') . ' ';
4906 4906
                         $return  .= '<a href="' . e($child1->url()) . '">' . $child1->getFullName() . '</a>';
@@ -4911,7 +4911,7 @@  discard block
 block discarded – undo
4911 4911
                         $dist[]  = $fam->family;
4912 4912
                     }
4913 4913
                 } elseif (!$one && $child1->canShow() && $child2->canShow()) {
4914
-                    $return  = '<li>';
4914
+                    $return = '<li>';
4915 4915
                     $return  .= '<a href="' . e($child2->url()) . '">' . $child2->getFullName() . '</a> ';
4916 4916
                     $return  .= I18N::translate('and') . ' ';
4917 4917
                     $return  .= '<a href="' . e($child1->url()) . '">' . $child1->getFullName() . '</a>';
@@ -5185,7 +5185,7 @@  discard block
 block discarded – undo
5185 5185
             $total = 10;
5186 5186
         }
5187 5187
         $sizes = explode('x', $size);
5188
-        $total = (int)$total;
5188
+        $total = (int) $total;
5189 5189
         $rows  = $this->runSql(
5190 5190
             " SELECT f_numchil AS tot, f_id AS id" .
5191 5191
             " FROM `##families`" .
@@ -5198,7 +5198,7 @@  discard block
 block discarded – undo
5198 5198
         }
5199 5199
         $tot = 0;
5200 5200
         foreach ($rows as $row) {
5201
-            $tot += (int)$row->tot;
5201
+            $tot += (int) $row->tot;
5202 5202
         }
5203 5203
         $chd = '';
5204 5204
         $chl = [];
@@ -5210,7 +5210,7 @@  discard block
 block discarded – undo
5210 5210
                 } else {
5211 5211
                     $per = round(100 * $row->tot / $tot, 0);
5212 5212
                 }
5213
-                $chd   .= $this->arrayToExtendedEncoding([$per]);
5213
+                $chd .= $this->arrayToExtendedEncoding([$per]);
5214 5214
                 $chl[] = htmlspecialchars_decode(strip_tags($family->getFullName())) . ' - ' . I18N::number($row->tot);
5215 5215
             }
5216 5216
         }
@@ -5556,7 +5556,7 @@  discard block
 block discarded – undo
5556 5556
             if ($max < $values->count) {
5557 5557
                 $max = $values->count;
5558 5558
             }
5559
-            $tot += (int)$values->count;
5559
+            $tot += (int) $values->count;
5560 5560
         }
5561 5561
         $unknown = $this->noChildrenFamiliesQuery() - $tot;
5562 5562
         if ($unknown > $max) {
@@ -5580,13 +5580,13 @@  discard block
 block discarded – undo
5580 5580
         $chm      .= 't' . $unknown . ',000000,0,' . $i . ',11,1';
5581 5581
         $chxl     .= I18N::translateContext('unknown century', 'Unknown') . '|1:||' . I18N::translate('century') . '|2:|0|';
5582 5582
         $step     = $max + 1;
5583
-        for ($d = (int)($max + 1); $d > 0; $d--) {
5583
+        for ($d = (int) ($max + 1); $d > 0; $d--) {
5584 5584
             if (($max + 1) < ($d * 10 + 1) && fmod(($max + 1), $d) == 0) {
5585 5585
                 $step = $d;
5586 5586
             }
5587 5587
         }
5588
-        if ($step == (int)($max + 1)) {
5589
-            for ($d = (int)($max); $d > 0; $d--) {
5588
+        if ($step == (int) ($max + 1)) {
5589
+            for ($d = (int) ($max); $d > 0; $d--) {
5590 5590
                 if ($max < ($d * 10 + 1) && fmod($max, $d) == 0) {
5591 5591
                     $step = $d;
5592 5592
                 }
@@ -5611,7 +5611,7 @@  discard block
 block discarded – undo
5611 5611
     private function topTenGrandFamilyQuery($type = 'list', $params = []): string
5612 5612
     {
5613 5613
         if (isset($params[0])) {
5614
-            $total = (int)$params[0];
5614
+            $total = (int) $params[0];
5615 5615
         } else {
5616 5616
             $total = 10;
5617 5617
         }
@@ -5709,8 +5709,8 @@  discard block
 block discarded – undo
5709 5709
      */
5710 5710
     private function commonSurnamesQuery($type = 'list', $show_tot = false, $params = []): string
5711 5711
     {
5712
-        $threshold          = empty($params[0]) ? 10 : (int)$params[0];
5713
-        $number_of_surnames = empty($params[1]) ? 10 : (int)$params[1];
5712
+        $threshold          = empty($params[0]) ? 10 : (int) $params[0];
5713
+        $number_of_surnames = empty($params[1]) ? 10 : (int) $params[1];
5714 5714
         $sorting            = empty($params[2]) ? 'alpha' : $params[2];
5715 5715
 
5716 5716
         $surnames = $this->topSurnames($number_of_surnames, $threshold);
@@ -5882,7 +5882,7 @@  discard block
 block discarded – undo
5882 5882
             $max_name  = 0;
5883 5883
             $top_name  = '';
5884 5884
             foreach ($surns as $spfxsurn => $count) {
5885
-                $per       = $count;
5885
+                $per = $count;
5886 5886
                 $count_per += $per;
5887 5887
                 // select most common surname from all variants
5888 5888
                 if ($per > $max_name) {
@@ -5906,11 +5906,11 @@  discard block
 block discarded – undo
5906 5906
                     ], $top_name);
5907 5907
             }
5908 5908
             $per   = round(100 * $count_per / $tot_indi, 0);
5909
-            $chd   .= $this->arrayToExtendedEncoding([$per]);
5909
+            $chd .= $this->arrayToExtendedEncoding([$per]);
5910 5910
             $chl[] = $top_name . ' - ' . I18N::number($count_per);
5911 5911
         }
5912 5912
         $per   = round(100 * ($tot_indi - $tot) / $tot_indi, 0);
5913
-        $chd   .= $this->arrayToExtendedEncoding([$per]);
5913
+        $chd .= $this->arrayToExtendedEncoding([$per]);
5914 5914
         $chl[] = I18N::translate('Other') . ' - ' . I18N::number($tot_indi - $tot);
5915 5915
 
5916 5916
         $chart_title = implode(I18N::$list_separator, $chl);
@@ -5932,12 +5932,12 @@  discard block
 block discarded – undo
5932 5932
     private function commonGivenQuery($sex = 'B', $type = 'list', $show_tot = false, $params = [])
5933 5933
     {
5934 5934
         if (isset($params[0]) && $params[0] != '' && $params[0] >= 0) {
5935
-            $threshold = (int)$params[0];
5935
+            $threshold = (int) $params[0];
5936 5936
         } else {
5937 5937
             $threshold = 1;
5938 5938
         }
5939 5939
         if (isset($params[1]) && $params[1] != '' && $params[1] >= 0) {
5940
-            $maxtoshow = (int)$params[1];
5940
+            $maxtoshow = (int) $params[1];
5941 5941
         } else {
5942 5942
             $maxtoshow = 10;
5943 5943
         }
@@ -6330,11 +6330,11 @@  discard block
 block discarded – undo
6330 6330
             } else {
6331 6331
                 $per = round(100 * $count / $tot_indi, 0);
6332 6332
             }
6333
-            $chd   .= $this->arrayToExtendedEncoding([$per]);
6333
+            $chd .= $this->arrayToExtendedEncoding([$per]);
6334 6334
             $chl[] = $givn . ' - ' . I18N::number($count);
6335 6335
         }
6336 6336
         $per   = round(100 * ($tot_indi - $tot) / $tot_indi, 0);
6337
-        $chd   .= $this->arrayToExtendedEncoding([$per]);
6337
+        $chd .= $this->arrayToExtendedEncoding([$per]);
6338 6338
         $chl[] = I18N::translate('Other') . ' - ' . I18N::number($tot_indi - $tot);
6339 6339
 
6340 6340
         $chart_title = implode(I18N::$list_separator, $chl);
@@ -6565,7 +6565,7 @@  discard block
 block discarded – undo
6565 6565
                     $datestamp = I18N::dateFormat();
6566 6566
                 }
6567 6567
 
6568
-                return FunctionsDate::timestampToGedcomDate((int)$user->getPreference('reg_timestamp'))->display(false, $datestamp);
6568
+                return FunctionsDate::timestampToGedcomDate((int) $user->getPreference('reg_timestamp'))->display(false, $datestamp);
6569 6569
             case 'regtime':
6570 6570
                 if (is_array($params) && isset($params[0]) && $params[0] != '') {
6571 6571
                     $datestamp = $params[0];
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
                     $datestamp = str_replace('%', '', I18N::timeFormat());
6574 6574
                 }
6575 6575
 
6576
-                return date($datestamp, (int)$user->getPreference('reg_timestamp'));
6576
+                return date($datestamp, (int) $user->getPreference('reg_timestamp'));
6577 6577
             case 'loggedin':
6578 6578
                 if (is_array($params) && isset($params[0]) && $params[0] != '') {
6579 6579
                     $yes = $params[0];
@@ -6913,9 +6913,9 @@  discard block
 block discarded – undo
6913 6913
             if ($value < 0) {
6914 6914
                 $value = 0;
6915 6915
             }
6916
-            $first    = (int)($value / 64);
6916
+            $first    = (int) ($value / 64);
6917 6917
             $second   = $value % 64;
6918
-            $encoding .= $xencoding[(int)$first] . $xencoding[(int)$second];
6918
+            $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second];
6919 6919
         }
6920 6920
 
6921 6921
         return $encoding;
@@ -7059,7 +7059,7 @@  discard block
 block discarded – undo
7059 7059
      */
7060 7060
     public function totalUserMessages(): string
7061 7061
     {
7062
-        $total = (int)Database::prepare("SELECT COUNT(*) FROM `##message` WHERE user_id = ?")
7062
+        $total = (int) Database::prepare("SELECT COUNT(*) FROM `##message` WHERE user_id = ?")
7063 7063
             ->execute([Auth::id()])
7064 7064
             ->fetchOne();
7065 7065
 
@@ -7074,7 +7074,7 @@  discard block
 block discarded – undo
7074 7074
     public function totalUserJournal(): string
7075 7075
     {
7076 7076
         try {
7077
-            $number = (int)Database::prepare("SELECT COUNT(*) FROM `##news` WHERE user_id = ?")
7077
+            $number = (int) Database::prepare("SELECT COUNT(*) FROM `##news` WHERE user_id = ?")
7078 7078
                 ->execute([Auth::id()])
7079 7079
                 ->fetchOne();
7080 7080
         } catch (PDOException $ex) {
@@ -7095,7 +7095,7 @@  discard block
 block discarded – undo
7095 7095
     public function totalGedcomNews(): string
7096 7096
     {
7097 7097
         try {
7098
-            $number = (int)Database::prepare("SELECT COUNT(*) FROM `##news` WHERE gedcom_id = ?")
7098
+            $number = (int) Database::prepare("SELECT COUNT(*) FROM `##news` WHERE gedcom_id = ?")
7099 7099
                 ->execute([$this->tree->getTreeId()])
7100 7100
                 ->fetchOne();
7101 7101
         } catch (PDOException $ex) {
Please login to merge, or discard this patch.
app/I18N.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -836,31 +836,31 @@
 block discarded – undo
836 836
         $year   = 365 * $day;
837 837
 
838 838
         if ($seconds > $year) {
839
-            $years = (int)($seconds / $year);
839
+            $years = (int) ($seconds / $year);
840 840
 
841 841
             return self::plural('%s year ago', '%s years ago', $years, self::number($years));
842 842
         }
843 843
 
844 844
         if ($seconds > $month) {
845
-            $months = (int)($seconds / $month);
845
+            $months = (int) ($seconds / $month);
846 846
 
847 847
             return self::plural('%s month ago', '%s months ago', $months, self::number($months));
848 848
         }
849 849
 
850 850
         if ($seconds > $day) {
851
-            $days = (int)($seconds / $day);
851
+            $days = (int) ($seconds / $day);
852 852
 
853 853
             return self::plural('%s day ago', '%s days ago', $days, self::number($days));
854 854
         }
855 855
 
856 856
         if ($seconds > $hour) {
857
-            $hours = (int)($seconds / $hour);
857
+            $hours = (int) ($seconds / $hour);
858 858
 
859 859
             return self::plural('%s hour ago', '%s hours ago', $hours, self::number($hours));
860 860
         }
861 861
 
862 862
         if ($seconds > $minute) {
863
-            $minutes = (int)($seconds / $minute);
863
+            $minutes = (int) ($seconds / $minute);
864 864
 
865 865
             return self::plural('%s minute ago', '%s minutes ago', $minutes, self::number($minutes));
866 866
         }
Please login to merge, or discard this patch.