summaryrefslogtreecommitdiff
path: root/app/Date
diff options
context:
space:
mode:
authorRico Sonntag <mail@ricosonntag.de>2018-09-23 00:32:55 +0200
committerGreg Roach <fisharebest@gmail.com>2018-09-22 23:32:55 +0100
commitb2ce94c6833c25934b40a7e6bc15985d50b5f42a (patch)
tree62b41467db3d26698ff21ed862461402d2febd1d /app/Date
parenta0cead57f9defbc64fdc8dfbbfb2cf01c516be57 (diff)
downloadwebtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.tar.gz
webtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.tar.bz2
webtrees-b2ce94c6833c25934b40a7e6bc15985d50b5f42a.zip
Reduced if/else complexity, removed not require else conditions (#1866)
* Reduced if/else complexity, removed not require else conditions * Fix indentation * Fix indentation * Use null-coalesce to simplify logic * Use null-coalesce to simplify logic * Use null-coalesce to simplify logic * Use null-coalesce to simplify logic * Use null-coalesce to simplify logic * Use null-coalesce to simplify logic * Admin theme no longer exists * Code style * Use null-coalesce operator to simplify logic
Diffstat (limited to 'app/Date')
-rw-r--r--app/Date/CalendarDate.php28
-rw-r--r--app/Date/JewishDate.php38
-rw-r--r--app/Date/JulianDate.php30
3 files changed, 49 insertions, 47 deletions
diff --git a/app/Date/CalendarDate.php b/app/Date/CalendarDate.php
index c6ffefd460..f15d1ed61c 100644
--- a/app/Date/CalendarDate.php
+++ b/app/Date/CalendarDate.php
@@ -472,11 +472,13 @@ class CalendarDate
{
if ($d1->maxJD < $d2->minJD) {
return -1;
- } elseif ($d2->maxJD < $d1->minJD) {
+ }
+
+ if ($d2->maxJD < $d1->minJD) {
return 1;
- } else {
- return 0;
}
+
+ return 0;
}
/**
@@ -822,9 +824,9 @@ class CalendarDate
{
if ($this->d > 9) {
return I18N::digits($this->d);
- } else {
- return I18N::digits('0' . $this->d);
}
+
+ return I18N::digits('0' . $this->d);
}
/**
@@ -906,9 +908,9 @@ class CalendarDate
{
if ($this->m > 9) {
return I18N::digits($this->m);
- } else {
- return I18N::digits('0' . $this->m);
}
+
+ return I18N::digits('0' . $this->m);
}
/**
@@ -965,9 +967,9 @@ class CalendarDate
{
if ($this->d == 0) {
return '';
- } else {
- return sprintf('%02d', $this->d);
}
+
+ return sprintf('%02d', $this->d);
}
/**
@@ -980,9 +982,9 @@ class CalendarDate
// Our simple lookup table doesn't work correctly for Adar on leap years
if ($this->m == 7 && $this->calendar instanceof JewishCalendar && !$this->calendar->isLeapYear($this->y)) {
return 'ADR';
- } else {
- return array_search($this->m, static::$MONTH_ABBREV);
}
+
+ return array_search($this->m, static::$MONTH_ABBREV);
}
/**
@@ -994,9 +996,9 @@ class CalendarDate
{
if ($this->y == 0) {
return '';
- } else {
- return sprintf('%04d', $this->y);
}
+
+ return sprintf('%04d', $this->y);
}
/**
diff --git a/app/Date/JewishDate.php b/app/Date/JewishDate.php
index 23d961ab92..09089d9d0b 100644
--- a/app/Date/JewishDate.php
+++ b/app/Date/JewishDate.php
@@ -64,9 +64,9 @@ class JewishDate extends CalendarDate
{
if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') {
return (new JewishCalendar())->numberToHebrewNumerals($this->d, true);
- } else {
- return parent::formatDay();
}
+
+ return parent::formatDay();
}
/**
@@ -81,9 +81,9 @@ class JewishDate extends CalendarDate
{
if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') {
return (new JewishCalendar())->numberToHebrewNumerals($this->y, false);
- } else {
- return parent::formatLongYear();
}
+
+ return parent::formatLongYear();
}
/**
@@ -95,9 +95,9 @@ class JewishDate extends CalendarDate
{
if (WT_LOCALE === 'he' || WT_LOCALE === 'yi') {
return (new JewishCalendar())->numberToHebrewNumerals($this->y, true);
- } else {
- return parent::formatLongYear();
}
+
+ return parent::formatLongYear();
}
/**
@@ -148,9 +148,9 @@ class JewishDate extends CalendarDate
if ($month_number === 7 && $leap_year) {
return $translated_month_names[-7];
- } else {
- return $translated_month_names[$month_number];
}
+
+ return $translated_month_names[$month_number];
}
/**
@@ -201,9 +201,9 @@ class JewishDate extends CalendarDate
if ($month_number === 7 && $leap_year) {
return $translated_month_names[-7];
- } else {
- return $translated_month_names[$month_number];
}
+
+ return $translated_month_names[$month_number];
}
/**
@@ -254,9 +254,9 @@ class JewishDate extends CalendarDate
if ($month_number === 7 && $leap_year) {
return $translated_month_names[-7];
- } else {
- return $translated_month_names[$month_number];
}
+
+ return $translated_month_names[$month_number];
}
/**
@@ -307,9 +307,9 @@ class JewishDate extends CalendarDate
if ($month_number === 7 && $leap_year) {
return $translated_month_names[-7];
- } else {
- return $translated_month_names[$month_number];
}
+
+ return $translated_month_names[$month_number];
}
/**
@@ -337,11 +337,11 @@ class JewishDate extends CalendarDate
$this->y,
8,
];
- } else {
- return [
- $this->y + ($this->m == 13 ? 1 : 0),
- ($this->m % 13) + 1,
- ];
}
+
+ return [
+ $this->y + ($this->m == 13 ? 1 : 0),
+ ($this->m % 13) + 1,
+ ];
}
}
diff --git a/app/Date/JulianDate.php b/app/Date/JulianDate.php
index 94caa2244b..2de79f40c9 100644
--- a/app/Date/JulianDate.php
+++ b/app/Date/JulianDate.php
@@ -52,9 +52,9 @@ class JulianDate extends CalendarDate
{
if ($year == -1) {
return 1;
- } else {
- return $year + 1;
}
+
+ return $year + 1;
}
/**
@@ -90,14 +90,14 @@ class JulianDate extends CalendarDate
if ($this->y < 0) {
return /* I18N: BCE=Before the Common Era, for Julian years < 0. See http://en.wikipedia.org/wiki/Common_Era */
I18N::translate('%s&nbsp;BCE', I18N::digits(-$this->y));
- } else {
- if ($this->new_old_style) {
- return I18N::translate('%s&nbsp;CE', I18N::digits(sprintf('%d/%02d', $this->y - 1, $this->y % 100)));
- } else {
- /* I18N: CE=Common Era, for Julian years > 0. See http://en.wikipedia.org/wiki/Common_Era */
- return I18N::translate('%s&nbsp;CE', I18N::digits($this->y));
- }
}
+
+ if ($this->new_old_style) {
+ return I18N::translate('%s&nbsp;CE', I18N::digits(sprintf('%d/%02d', $this->y - 1, $this->y % 100)));
+ }
+
+ /* I18N: CE=Common Era, for Julian years > 0. See http://en.wikipedia.org/wiki/Common_Era */
+ return I18N::translate('%s&nbsp;CE', I18N::digits($this->y));
}
/**
@@ -109,12 +109,12 @@ class JulianDate extends CalendarDate
{
if ($this->y < 0) {
return sprintf('%04d B.C.', -$this->y);
- } else {
- if ($this->new_old_style) {
- return sprintf('%04d/%02d', $this->y - 1, $this->y % 100);
- } else {
- return sprintf('%04d', $this->y);
- }
}
+
+ if ($this->new_old_style) {
+ return sprintf('%04d/%02d', $this->y - 1, $this->y % 100);
+ }
+
+ return sprintf('%04d', $this->y);
}
}