Skip to content

Commit

Permalink
Fix phpstan Ternary operator condition is always true.
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-wolf-gb committed Feb 12, 2024
1 parent 80ef304 commit f7c8094
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Countries/Tunisia.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Spatie\Holidays\Countries;

use Carbon\CarbonImmutable;
use RuntimeException;

class Tunisia extends Country
{
Expand Down Expand Up @@ -372,8 +371,7 @@ protected function getIslamicHolidays(
if ($year != 1970) {
$previousHoliday = is_array($holidays[$year - 1]) ? $holidays[$year - 1][1] : $holidays[$year - 1];

$previousHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year - 1) . '-' . $previousHoliday)
?: throw new RuntimeException('Date could not be created.');
$previousHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year - 1) . '-' . $previousHoliday);

if ($previousHoliday->addDays($day - 1)->year == $year) {
$islamicHolidays = $this->prepareHolidays(
Expand All @@ -389,8 +387,7 @@ protected function getIslamicHolidays(
$currentYearHolidays = is_array($holidays[$year]) ? $holidays[$year] : [$holidays[$year]];

foreach ($currentYearHolidays as $currentYearHoliday) {
$currentYearHoliday = CarbonImmutable::createFromFormat('Y-m-d', "$year-$currentYearHoliday")
?: throw new RuntimeException('Date could not be created.');
$currentYearHoliday = CarbonImmutable::createFromFormat('Y-m-d', "$year-$currentYearHoliday");

$islamicHolidays = array_merge($islamicHolidays, $this->prepareHolidays(
holiday: $currentYearHoliday,
Expand All @@ -405,8 +402,7 @@ protected function getIslamicHolidays(
if ($year != 2037) {
$nextHoliday = is_array($holidays[$year + 1]) ? $holidays[$year + 1][1] : $holidays[$year + 1];

$nextHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year + 1) . '-' . $nextHoliday)
?: throw new RuntimeException('Date could not be created.');
$nextHoliday = CarbonImmutable::createFromFormat('Y-m-d', ($year + 1) . '-' . $nextHoliday);

if ($nextHoliday->addDays(-1)->year == $year) {
$islamicHolidays = array_merge($islamicHolidays, $this->prepareHolidays(
Expand Down

0 comments on commit f7c8094

Please sign in to comment.